package com.ss.android.video;

import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.os.Build;
import android.os.Message;
import android.os.SystemClock;
import android.provider.Settings;
import android.support.v4.content.ContextCompat;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.TextureView;
import android.view.View;
import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnWindowFocusChangeListener;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;

import com.bytedance.article.common.a.g;
import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.UIUtils;
import com.bytedance.common.utility.collection.WeakHandler;
import com.bytedance.common.utility.collection.WeakHandler.Callback;
import com.bytedance.frameworks.baselib.network.http.util.TaskInfo;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.app.BizApplication;
import com.ss.android.article.base.feature.app.c.ImageManager;
import com.ss.android.article.base.feature.e.ArticleShareHelper;
import com.ss.android.article.base.feature.e.VideoAutoPlayHelperDetail;
import com.ss.android.article.base.feature.feed.c.FeedDownloadAppAd;
import com.ss.android.article.base.feature.model.Article;
import com.ss.android.article.base.feature.model.CellRef;
import com.ss.android.article.base.feature.video.DialogShowHelper;
import com.ss.android.article.base.feature.video.IMediaCallback;
import com.ss.android.article.base.feature.video.IMediaLayout;
import com.ss.android.article.base.feature.video.IMediaViewLayout;
import com.ss.android.article.base.feature.video.VideoClarityHelper;
import com.ss.android.article.base.ui.AdButtonLayout;
import com.ss.android.article.base.ui.DrawableButton;
import com.ss.android.article.base.utils.ArticleHelper;
import com.ss.android.article.common.ScreenOrientationObserver;
import com.ss.android.b.a.BaseAdsData;
import com.ss.android.common.dialog.AlertDialog;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.common.ui.view.AlphaImageView;
import com.ss.android.image.AsyncImageView;
import com.ss.android.image.loader.ImageLoader;
import com.ss.android.image.model.ImageInfo;
import com.ss.android.newmedia.BaseApplication;
import com.ss.android.video.renderview.IRenderCallback;
import com.ss.android.video.renderview.IRenderView;
import com.ss.ttvideoengine.b.VideoItem;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.EnumSet;
import java.util.Locale;

public final class MediaViewLayout implements Callback, IMediaLayout, IMediaViewLayout, ScreenOrientationObserver.OrientationChangeListener, IRenderCallback {
    private static final int MSG_DISMISS_TOOLBAR = 1;
    private static int Q = Build.VERSION.SDK_INT;
    final ScreenOrientationObserver L;
    public IRenderView mVideoSurface;
    float mLastX;
    float mLastY;
    int mInitialX;
    int mInitialY;
    boolean E = true;
    boolean isDragging = false;
    boolean isTouchVertical = false;
    boolean isDirectPlay = false;
    boolean I = false;
    boolean J = false;
    boolean isLiveVideo = false;
    int mWidth = 0;
    int mHeight = 0;
    int mAutoPlayDelaySeconds = 5;
    Article mArticle;
    View mVideoBottomLayout;
    ImageView mVideoPlay;
    View mVideoTopLayout;
    TextView mVideoFullscreenTitle;
    TextView mVideoCurrentTime;
    ImageView mBatteryLevel;
    View mFinishInfoLayout;
    View mVideoLoadingRetryLayout;
    RelativeLayout mVideoCoverContainer;
    RelativeLayout mVideoAutoPlayLayout;
    TextView mTvAutoPlay;
    TextView mFullscreenAutoPlayEndCoverTvAutoPlay;
    View mAdActionLayout;
    ImageView mAdSplashSkipLoading;
    ViewGroup mVideoAreaRight;
    int q = 0;
    WeakHandler mWeakHandler = new WeakHandler(this);
    Context mContext;
    boolean isFullscreen = false;
    boolean isCellType;
    boolean v;
    BroadcastReceiver mBatteryChangedReceiver = null;
    int mLastWidth;
    int mLastHeight;
    IMediaCallback callback;
    private View mMediaRoot;
    private ImageView mIvWatermark;
    private TextView mVideoBack;
    private ImageView mVideoClose;
    private ImageView mVideoMoreIv;
    private ImageView mVideoItemFeedMoreDot;
    private ImageView mVideoBottomBarBGIv;
    private SeekBar mSeekBar;
    private ProgressBar mVideoProgress;
    private RelativeLayout mVideoLoadingCover;
    private AsyncImageView mVideoLoadingCoverImage;
    private View mAutoPlayEndCover;
    private TextView mAutoPlayEndCoverTvVideoTitle;
    private AsyncImageView mAutoPlayEndCoverVideoEndCoverImageIv;
    private TextView mTvCancelAutoPlay;
    private View mFullscreenAutoPlayEndCover;
    private TextView mFullscreenAutoPlayEndCoverTvVideoTitle;
    private AsyncImageView mFullscreenAutoPlayEndCoverVideoEndCoverImageIv;
    private TextView mFullscreenAutoPlayEndCoverTvCancelAutoPlay;
    private Dialog mVolumeDialog;
    private ProgressBar mVolumeProgressBar;
    private TextView mTvVolume;
    private ImageView mVolumeImageTip;
    private Dialog mVideoProgressDialog;
    private ProgressBar mDurationProgressBar;
    private ImageView mDurationImageTip;
    private TextView mTvCurrent;
    private TextView mTvDuration;
    private TextView mAdLeftTime;
    private TextView mAdJumpBtn;
    private View mAdLeftJumpLine;
    private View mVideoAdBottomLayout;
    private View mVideoAdGoDetailBottom;
    private ImageView mVideoAdFullscreen;
    private FrameLayout mAdSplashIgnore;
    private TextView mVideoTimeLeftTime;
    private TextView mVideoTimePlay;
    private ImageView mVideoFullscreen;
    private AsyncImageView mMediaThirdParty;
    private TextView mVideoTitle;
    private DrawableButton mVideoFollowCompleteReplay;
    private DrawableButton mVideoFollowCompleteShare;
    private AsyncImageView mVideoFinishCoverImage;
    private TextView mCoverTitle;
    private DrawableButton mVideoTime;
    protected View mRLVideoEndCover;
    private AlphaImageView mIvShareWechat;
    private AlphaImageView mIvShareMoment;
    private AlphaImageView mIvShareQQ;
    private AlphaImageView mIvShareQzone;
    private View mLLReplay;
    private ImageView mVideoFullscreenBack;
    private View mVideoLoadingProgress;
    private View mVideoLoadingRetry;
    private ImageView mVideoRetry;
    private TextView mVideoRetryDes;
    private ImageView mVideoCoverImage;
    private TextView mVideoCoverGoDetail;
    private ImageView mVideoCoverReplay;
    private TextView mVideoAdGoDetail;
    private AdButtonLayout mLargeButtonAd;
    private float mLastVideoTimeLeftTimeTextSize;
    private ColorStateList mLastVideoTimeLeftTimeTextColor;
    private float mLastVideoTimeLeftTimeAlpha;
    private Rect mShrinkVideoTimeLeftTimeMargins = new Rect();
    private int mPotraitVideoBottomLayoutHeight = 0;
    private ColorStateList mShrinkVideoFullscreenTitleTextColor;
    private float mShrinkVideoFullscreenTitleAlpha;
    private Rect mFullscreenTitleMargins = new Rect();
    private int mShrinkVideoTopLayoutHeight = 0;
    private boolean bJ;
    private int mOuterVideoCellType = 3;
    private ImageLoader mImageLoader;
    private boolean isSurfaceCreated;
    private int bN;
    private String mThirdImageUrl;
    private boolean bP;
    private boolean needInitVideoProgressBar;
    private boolean bR = false;
    private boolean bS = true;
    private boolean isDetailAutoPlayKeepFullScreen = false;
    private View mMediaPlayLayout;
    private EnumSet bV;
    private boolean bW = false;
    private WindowManager mWindowManager;
    private Article mNextVideoArticle = null;
    private MyOnGlobalLayoutListener mMyOnGlobalLayoutListener;
    private ImageView mAdSplashHasWifiLoaded;
    private TextView mAdSplashJumpBtn;
    private ImageView mAdSplashLogo;
    private View mVideoLiveBottomLayout;
    private DrawableButton mVideoLiveTip;
    private ImageView mVideoLiveFullScreen;
    private View mVideoLiveCoverContainer;
    private TextView mLiveVideoStatus;
    private View mVideoCoverBack;
    private View mVideoLiveCoverBack;
    private TextView mVideoActionControlAreaRight;
    private Dialog mDialog = null;
    private int mContainerWidth;
    private int mContainerHeight;
    private int mVideoWidth;
    private int mVideoHeight;
    private int mPortraitTopMargin = 0;
    private int mPortraitLeftMargin = 0;
    private int mPortraitWidth = 0;
    private int mPortraitHeight = 0;
    private int mPortraitRule = 0;
    private Rect mPotraitMargins = new Rect();
    private float mLastVideoTimePlayTextSize;
    private ColorStateList mLastVideoTimePlayTextColor;
    private float mLastVideoTimePlayAlpha;
    private Rect mShrinkVideoTimePlayMargins = new Rect();
    private boolean isTouchEdge;
    private View.OnTouchListener mMediaRootTouchListener = new View.OnTouchListener() {

        public final boolean onTouch(View view, MotionEvent motionEvent) {
            MediaViewLayout.this.translatioXVideoAreaRight(true);
            float x = motionEvent.getX();
            float y = motionEvent.getY();
            switch (motionEvent.getAction()) {
                case MotionEvent.ACTION_DOWN: {
                    MediaViewLayout.this.isTouchEdge = MediaViewLayout.touchEdge(motionEvent);
                    mLastX = x;
                    mLastY = y;
                    mInitialX = ((int) x);
                    mInitialY = ((int) y);
                    MediaViewLayout.this.E = true;
                    if (mFinishInfoLayout != null && mFinishInfoLayout.getVisibility() == View.VISIBLE) {
                        break;
                    }

                    if (mBatteryChangedReceiver == null) {
                        mBatteryChangedReceiver = new BatteryChangedReceiver();
                        mContext.registerReceiver(mBatteryChangedReceiver, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
                    }
                    if (MediaViewLayout.this.isFullScreen()) {
                        String time = new SimpleDateFormat("HH:mm", Locale.getDefault()).format(new Date());
                        Logger.d("MediaViewLayout", time);
                        mVideoCurrentTime.setText(time);
                        mBatteryLevel.setVisibility(View.VISIBLE);
                    } else {
                        mVideoCurrentTime.setText("");
                        mBatteryLevel.setVisibility(View.GONE);
                    }

                    if (MediaViewLayout.this.E && !MediaViewLayout.this.isDirectPlay) {
                        boolean v5;
                        boolean v0_2;
                        boolean v2_1;
                        if (MediaViewLayout.this.J || MediaViewLayout.this.I) {
                            v5 = false;
                        } else {
                            if (mVideoBottomLayout.getVisibility() == View.VISIBLE) {
                                MediaViewLayout.this.dismissToolBar();
                                v2_1 = false;
                                v5 = v2_1;
                                v0_2 = false;
                            } else {
                                if ((MediaViewLayout.this.isCellType) && !MediaViewLayout.this.isFullscreen) {
                                    v0_2 = true;
                                    v5 = true;
                                } else {
                                    v2_1 = true;
                                    v5 = v2_1;
                                    v0_2 = false;
                                }
                            }
                            MediaViewLayout.this.trySetTitleVisiable(v0_2);
                        }

                        if (!MediaViewLayout.this.I) {
                            v0_2 = v5;
                        } else if (mVideoPlay.getVisibility() != View.VISIBLE) {
                            v0_2 = true;
                        } else {
                            v0_2 = false;
                        }

                        if (MediaViewLayout.this.nonNullCallback()) {
                            v2_1 = mVideoLoadingRetryLayout.getVisibility() != View.VISIBLE;
                            MediaViewLayout.this.callback.handleRootViewClick(MediaViewLayout.this, view, v0_2, v2_1);
                        }
                    }

                    if (MediaViewLayout.this.I && isFullscreen) {
                        mVideoTopLayout.setVisibility(View.VISIBLE);
                        mVideoFullscreenTitle.setVisibility(View.GONE);
                    }
                    MediaViewLayout.this.E = true;
                    break;
                }
                case MotionEvent.ACTION_UP: {
                    if (Math.abs(x - (float) mInitialX) > 20f
                            || Math.abs(y - (float) mInitialY) > 20f) {
                        MediaViewLayout.this.E = false;
                    }
                    if (!isFullscreen) {
                        MediaViewLayout.this.E = true;
                    }
                    MediaViewLayout.this.isDragging = false;
                    mLastX = 0f;
                    mLastY = 0f;
                    mInitialX = 0;
                    MediaViewLayout.this.dismissVolume();
                    if (MediaViewLayout.this.nonNullCallback()) {
                        MediaViewLayout.this.callback.handleTouchUp();
                    }
                    MediaViewLayout.this.isTouchEdge = false;
                    break;
                }
                case MotionEvent.ACTION_MOVE: {
                    if (!MediaViewLayout.this.isFullscreen) {
                        break;
                    }

                    if (MediaViewLayout.this.isTouchEdge) {
                        break;
                    }

                    float deltaX = x - mLastX;
                    float deltaY = y - mLastY;
                    float absDeltaX = Math.abs(deltaX);
                    float absDeltaY = Math.abs(deltaY);
                    if (!MediaViewLayout.this.isDragging) {
                        if (absDeltaX <= 20f && absDeltaY <= 20f) {
                            return true;
                        }
                        MediaViewLayout.this.isTouchVertical = absDeltaX <= absDeltaY;
                        MediaViewLayout.this.isDragging = true;
                    }

                    MediaViewLayout.this.dismissToolBar();
                    MediaViewLayout.this.trySetTitleVisiable(false);
                    if (MediaViewLayout.this.isTouchVertical) {
                        if (deltaY > 0f) {
                            if ((MediaViewLayout.this.isFullscreen) && (MediaViewLayout.this.nonNullCallback())) {
                                MediaViewLayout.this.callback.handleVolume(absDeltaY, false, MediaViewLayout.this.getVolume());
                            }
                        } else if (deltaY < 0f) {
                            if ((MediaViewLayout.this.isFullscreen) && (MediaViewLayout.this.nonNullCallback())) {
                                MediaViewLayout.this.callback.handleVolume(absDeltaY, true, MediaViewLayout.this.getVolume());
                            }
                        }
                    } else if (deltaX > 0f) {
                        if ((MediaViewLayout.this.isFullscreen) && (MediaViewLayout.this.nonNullCallback()) && !MediaViewLayout.this.I) {
                            MediaViewLayout.this.callback.handleTouchProgress(absDeltaX, true);
                        }
                    } else if (deltaX < 0f) {
                        if ((MediaViewLayout.this.isFullscreen) && (MediaViewLayout.this.nonNullCallback()) && !MediaViewLayout.this.I) {
                            MediaViewLayout.this.callback.handleTouchProgress(absDeltaX, false);
                        }
                    }

                    mLastX = x;
                    mLastY = y;
                    break;
                }
                case MotionEvent.ACTION_CANCEL: {
                    MediaViewLayout.this.isTouchEdge = false;
                    break;
                }
            }
            if (!MediaViewLayout.this.isFullscreen && MediaViewLayout.this.isCellType) {
                return false;
            }
            return true;
        }
    };
    private OnLayoutChangeListener mMediaRootLayoutChangeListener = new View.OnLayoutChangeListener() {

        @Override
        public final void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            mWidth = v.getWidth();
            mHeight = v.getHeight();
            Logger.d("MediaViewLayout", "width:" + mWidth + ",height:" + mHeight);
            if (mLastHeight != mHeight
                    || mLastWidth != mWidth) {
                mLastWidth = mWidth;
                mLastHeight = mHeight;
                MediaViewLayout.this.setPlayerSurfaceViewSize(true);
            }
        }
    };
    private boolean isAutoRotateEnabled = true;
    private long mSurfaceChangedTime;
    private int cf = this.getScreenRotation();
    private Runnable mEndCoverCountdownRunnable = new Runnable() {

        public final void run() {
            --mAutoPlayDelaySeconds;
            if (mAutoPlayDelaySeconds == 0) {
                MediaViewLayout.this.dismissAllEndCover();
                if ((MediaViewLayout.this.nonNullCallback()) && !MediaViewLayout.this.isCellType) {
                    VideoAutoPlayHelperDetail videoAutoPlayHelperDetail = MediaViewLayout.this.callback.getVideoAutoPlayHelperDetail();
                    if (videoAutoPlayHelperDetail != null) {
                        videoAutoPlayHelperDetail.reportNextPlay(mContext, MediaViewLayout.this.isFullscreen, true, true);
                    }
                    UIUtils.setVisibility(mVideoAutoPlayLayout, View.GONE);
                    MediaViewLayout.this.callback.getVideoAutoPlayHelperDetail().a(MediaViewLayout.this.callback);
                }
            } else {
                String autoPlayTxt = mAutoPlayDelaySeconds + mContext.getString(com.ss.android.article.browser.R.string.after_x_seconds_auto_play);
                int length = autoPlayTxt.length();
                SpannableStringBuilder builder = new SpannableStringBuilder(autoPlayTxt);
                ForegroundColorSpan foregroundColorSpanPrefix = new ForegroundColorSpan(mContext.getResources().getColor(com.ss.android.article.browser.R.color.ssxinzi4));
                ForegroundColorSpan foregroundColorSpanSuffix = new ForegroundColorSpan(mContext.getResources().getColor(com.ss.android.article.browser.R.color.cg));
                builder.setSpan(foregroundColorSpanPrefix, 0, 1, 33);
                builder.setSpan(foregroundColorSpanSuffix, 1, length, 33);
                UIUtils.setText(mFullscreenAutoPlayEndCoverTvAutoPlay, builder);
                UIUtils.setText(mTvAutoPlay, builder);
                mWeakHandler.postDelayed(this, 1000L);
            }
        }
    };

    public MediaViewLayout(Context context, View mediaPlayLayout, boolean isFromFeed, EnumSet enumSet) {
        WindowManager windowManager = null;
        this.isCellType = true;
        this.v = false;
        mLastWidth = 0;
        mLastHeight = 0;
        this.bP = false;
        this.needInitVideoProgressBar = false;
        this.L = new ScreenOrientationObserver(context);
        if ((context instanceof Activity)) {
            windowManager = ((Activity) context).getWindowManager();
        }
        mWindowManager = windowManager;
        mContext = BizApplication.getApplication();
        mMediaPlayLayout = mediaPlayLayout;
        mMediaRoot = mMediaPlayLayout;
        this.isCellType = isFromFeed;
        DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
        mLastWidth = displayMetrics.widthPixels;
        mLastHeight = displayMetrics.heightPixels;
        mImageLoader = new ImageLoader(context,
                new TaskInfo(),
                16,
                20,
                2, new ImageManager(context), mLastWidth, mLastHeight);
        if (enumSet == null) {
            enumSet = EnumSet.noneOf(CtrlFlag.class);
        }
        this.bV = enumSet;
        this.bP = true;
        this.needInitVideoProgressBar = true;
        new PorterDuffColorFilter(Color.parseColor("#CACACA"), PorterDuff.Mode.SRC_IN);
        this.setVisibility(View.GONE);
        this.initView(mMediaRoot);
        this.bindListener();
        if (Build.VERSION.SDK_INT >= 18) {
            mMediaRoot.getViewTreeObserver().addOnWindowFocusChangeListener(new MyOnWindowFocusChangeListener(mVideoSurface));
        }
        mVideoSurface.setWindowVisibilityChangedListener(new IRenderView.WindowVisibilityChangedListener(this));
    }

    static boolean touchEdge(MotionEvent motionEvent) {
        if (motionEvent.getActionMasked() == 0) {
            int screenWidth = UIUtils.getScreenWidth(BaseApplication.getApplication());
            int screenHeight = UIUtils.getScreenHeight(BaseApplication.getApplication());
            float rawX = motionEvent.getRawX();
            float rawY = motionEvent.getRawY();
            if (rawX > (float) screenWidth * 0.01f
                    && rawX < (float) screenWidth * 0.99f
                    && rawY > (float) screenHeight * 0.01f
                    && rawY < (float) screenHeight * 0.99f) {
                return false;
            } else {
                return true;
            }
        } else {
            return false;
        }
    }

    private static String convert2readableString(long time) {
        StringBuilder stringBuilder = new StringBuilder();
        long minutes = time / 60000;
        long seconds = time % 3600000 % 60000 / 1000;
        if (minutes >= 10L) {
            stringBuilder.append(minutes);
        } else if (minutes > 0L) {
            stringBuilder.append(0);
            stringBuilder.append(minutes);
        } else {
            stringBuilder.append(0);
            stringBuilder.append(0);
        }

        stringBuilder.append(":");
        if (seconds >= 10L) {
            stringBuilder.append(seconds);
        } else if (seconds > 0L) {
            stringBuilder.append(0);
            stringBuilder.append(seconds);
        } else {
            stringBuilder.append(0);
            stringBuilder.append(0);
        }

        return stringBuilder.toString();
    }

    static void startTranslationX(View view, float arg5, boolean arg6) {
        ObjectAnimator.ofFloat(view, "translationX", new float[]{0f}).setDuration(200).start();
    }

    private static void setLayout(ImageView imageView, int width, int height) {
        ViewGroup.LayoutParams lp = imageView.getLayoutParams();
        if (lp != null) {
            if (width > 0) {
                lp.width = width;
            }

            if (height > 0) {
                lp.height = height;
            }
            imageView.setLayoutParams(lp);
        }
    }

    private static boolean getVivoMultiWindowActive() {
        if (AppData.getInstance().isVivoMultiwindow != -1) {
            return AppData.getInstance().isVivoMultiwindow == 1;
        }
        BufferedReader bufferedReader = null;
        BufferedReader bufferedReader1 = null;
        Process process = null;
        Process process1 = null;
        try {
            process = Runtime.getRuntime().exec("getprop persist.vivo.multiwindow");
            process1 = Runtime.getRuntime().exec("getprop persist.vivo.multiwindow_active");
            bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()), 1024);
            String line = bufferedReader.readLine();
            bufferedReader1 = new BufferedReader(new InputStreamReader(process1.getInputStream()), 1024);
            String line1 = bufferedReader1.readLine();
            if (line != null
                    && line1 != null
                    && android.support.design.a.isTextEquals(line, "true")
                    && (android.support.design.a.isTextEquals(line1, "true"))) {
                AppData.getInstance().setVivoMultiWindowActive(1);
                return true;
            }
            AppData.getInstance().setSessionId(0L);
            return false;
        } catch (Exception e) {
            return false;
        } finally {
            if (process != null) {
                try {
                    process.destroy();
                } catch (Exception e) {

                }
            }

            if (process1 != null) {
                try {
                    process1.destroy();
                } catch (Exception e) {

                }
            }
            if (bufferedReader1 != null) {
                try {
                    bufferedReader1.close();
                } catch (Exception e) {

                }
            }
            if (bufferedReader != null) {
                try {
                    bufferedReader.close();
                } catch (Exception e) {

                }
            }

        }
    }

    final boolean nonNullCallback() {
        if (this.callback == null) {
            Logger.e("MediaViewLayout", "callback is null");
            return false;
        } else {
            return true;
        }
    }

    final void translatioXVideoAreaRight(boolean anim) {
        if (mVideoAreaRight.getChildCount() > 0 && mVideoAreaRight.getTranslationX() <= 0f) {
            if (anim) {
                startTranslationX(mVideoAreaRight, (float) mVideoAreaRight.getWidth(), true);
            } else {
                mVideoAreaRight.setTranslationX((float) mVideoAreaRight.getWidth());
            }
        }
    }

    private void initView(View view) {
        MediaViewLayoutHolder mediaViewLayoutHolder;
        if (view.getTag() == null) {
            mediaViewLayoutHolder = new MediaViewLayoutHolder();
            mediaViewLayoutHolder.mVideoSurface = view.findViewById(com.ss.android.article.browser.R.id.video_surface);
            mediaViewLayoutHolder.mVideoBack = view.findViewById(com.ss.android.article.browser.R.id.video_back);
            mediaViewLayoutHolder.mIvWatermark = view.findViewById(com.ss.android.article.browser.R.id.video_water_mark);
            mediaViewLayoutHolder.mVideoClose = view.findViewById(com.ss.android.article.browser.R.id.video_close);
            mediaViewLayoutHolder.mVideoTopLayout = view.findViewById(com.ss.android.article.browser.R.id.video_top_layout);
            mediaViewLayoutHolder.mVideoFullscreenBack = view.findViewById(com.ss.android.article.browser.R.id.video_fullscreen_back);
            mediaViewLayoutHolder.mVideoTitle = view.findViewById(com.ss.android.article.browser.R.id.video_title);
            mediaViewLayoutHolder.mVideoFullscreenTitle = view.findViewById(com.ss.android.article.browser.R.id.video_fullscreen_title);
            mediaViewLayoutHolder.mVideoCurrentTime = view.findViewById(com.ss.android.article.browser.R.id.video_current_time);
            mediaViewLayoutHolder.mBatteryLevel = view.findViewById(com.ss.android.article.browser.R.id.battery_level);
            mediaViewLayoutHolder.mVideoBottomLayout = view.findViewById(com.ss.android.article.browser.R.id.video_bottom_layout);
            mediaViewLayoutHolder.mVideoPlay = view.findViewById(com.ss.android.article.browser.R.id.video_play);
            mediaViewLayoutHolder.mVideoMoreIv = view.findViewById(com.ss.android.article.browser.R.id.iv_more_icon);
            mediaViewLayoutHolder.mVideoItemFeedMoreDot = view.findViewById(com.ss.android.article.browser.R.id.item_feed_more_dot);
            mediaViewLayoutHolder.mVideoBottomBarBGIv = view.findViewById(com.ss.android.article.browser.R.id.video_bottom_bar_bg);
            mediaViewLayoutHolder.mVideoSeekBar = view.findViewById(com.ss.android.article.browser.R.id.video_seekbar);
            mediaViewLayoutHolder.mMediaThirdParty = view.findViewById(com.ss.android.article.browser.R.id.media_third_party);
            mediaViewLayoutHolder.mVideoProgress = view.findViewById(com.ss.android.article.browser.R.id.video_progress);
            mediaViewLayoutHolder.mVideoTimeLeftTime = view.findViewById(com.ss.android.article.browser.R.id.video_time_left_time);
            mediaViewLayoutHolder.mVideoTimePlay = view.findViewById(com.ss.android.article.browser.R.id.video_time_play);
            mediaViewLayoutHolder.mVideoLoadingRetryLayout = view.findViewById(com.ss.android.article.browser.R.id.video_loading_retry_layout);
            mediaViewLayoutHolder.mVideoFullscreen = view.findViewById(com.ss.android.article.browser.R.id.video_full_screen);
            mediaViewLayoutHolder.mVideoLoadingProgress = view.findViewById(com.ss.android.article.browser.R.id.video_loading_progress);
            mediaViewLayoutHolder.mVideoLoadingRetry = view.findViewById(com.ss.android.article.browser.R.id.video_loading_retry);
            mediaViewLayoutHolder.mVideoRetry = view.findViewById(com.ss.android.article.browser.R.id.video_retry);
            mediaViewLayoutHolder.mVideoRetryDes = view.findViewById(com.ss.android.article.browser.R.id.video_retry_des);
            mediaViewLayoutHolder.mVideoCoverContainer = view.findViewById(com.ss.android.article.browser.R.id.video_cover_container);
            mediaViewLayoutHolder.mVideoCoverImage = view.findViewById(com.ss.android.article.browser.R.id.video_cover_image);
            mediaViewLayoutHolder.mVideoCoverGoDetail = view.findViewById(com.ss.android.article.browser.R.id.video_cover_godetail);
            mediaViewLayoutHolder.mVideoCoverReplay = view.findViewById(com.ss.android.article.browser.R.id.video_cover_replay);
            mediaViewLayoutHolder.mVideoAdGoDetail = view.findViewById(com.ss.android.article.browser.R.id.video_ad_godetail);
            mediaViewLayoutHolder.mVideoLoadingCover = view.findViewById(com.ss.android.article.browser.R.id.video_loading_cover);
            mediaViewLayoutHolder.mVideoLoadingCoverImage = view.findViewById(com.ss.android.article.browser.R.id.video_loading_cover_image);
            mediaViewLayoutHolder.mVideoAutoPlayLayout = view.findViewById(com.ss.android.article.browser.R.id.video_auto_play_layout);
            view.findViewById(com.ss.android.article.browser.R.id.tv_playing_soon);
            view.findViewById(com.ss.android.article.browser.R.id.a1u);
            view.findViewById(com.ss.android.article.browser.R.id.a1s);
            view.findViewById(com.ss.android.article.browser.R.id.video_play_icon);
            view.findViewById(com.ss.android.article.browser.R.id.tv_cancel_auto_play);
            mediaViewLayoutHolder.mAutoPlayEndCover = view.findViewById(com.ss.android.article.browser.R.id.ll_video_auto_play_end_cover);
            mediaViewLayoutHolder.mAutoPlayEndCoverTvAutoPlay = mediaViewLayoutHolder.mAutoPlayEndCover.findViewById(com.ss.android.article.browser.R.id.tv_auto_play);
            mediaViewLayoutHolder.mAutoPlayEndCoverTvVideoTitle = mediaViewLayoutHolder.mAutoPlayEndCover.findViewById(com.ss.android.article.browser.R.id.video_title);
            mediaViewLayoutHolder.mAutoPlayEndCoverVideoEndCoverImageIv = mediaViewLayoutHolder.mAutoPlayEndCover.findViewById(com.ss.android.article.browser.R.id.video_end_cover_image);
            mediaViewLayoutHolder.mAutoPlayTvCancelAutoPlay = mediaViewLayoutHolder.mAutoPlayEndCover.findViewById(com.ss.android.article.browser.R.id.tv_cancel_auto_play);
            mediaViewLayoutHolder.mAutoPlayEndCover.findViewById(com.ss.android.article.browser.R.id.iv_paly);
            mediaViewLayoutHolder.mFullscreenAutoPlayEndCover = view.findViewById(com.ss.android.article.browser.R.id.ll_video_autoplay_end_cover_fullscreen);
            mediaViewLayoutHolder.mFullscreenAutoPlayEndCoverTvAutoPlay = mediaViewLayoutHolder.mFullscreenAutoPlayEndCover.findViewById(com.ss.android.article.browser.R.id.tv_auto_play);
            mediaViewLayoutHolder.mFullscreenAutoPlayEndCoverTvVideoTitle = mediaViewLayoutHolder.mFullscreenAutoPlayEndCover.findViewById(com.ss.android.article.browser.R.id.video_title);
            mediaViewLayoutHolder.mFullscreenAutoPlayEndCoverVideoEndCoverImageIv = mediaViewLayoutHolder.mFullscreenAutoPlayEndCover.findViewById(com.ss.android.article.browser.R.id.video_end_cover_image);
            mediaViewLayoutHolder.mFullscreenAutoPlayEndCoverTvCancelAutoPlay = mediaViewLayoutHolder.mFullscreenAutoPlayEndCover.findViewById(com.ss.android.article.browser.R.id.tv_cancel_auto_play);
            mediaViewLayoutHolder.mFullscreenAutoPlayEndCover.findViewById(com.ss.android.article.browser.R.id.iv_paly);
            mediaViewLayoutHolder.mFinishInfoLayout = view.findViewById(com.ss.android.article.browser.R.id.finish_info_layout);
            mediaViewLayoutHolder.mVideoFollowCompleteReplay = view.findViewById(com.ss.android.article.browser.R.id.video_follow_complete_replay);
            mediaViewLayoutHolder.mVideoFollowCompleteShare = view.findViewById(com.ss.android.article.browser.R.id.video_follow_complete_share);
            mediaViewLayoutHolder.mVideoFinishCoverImage = view.findViewById(com.ss.android.article.browser.R.id.video_finish_cover_image);
            if (Build.VERSION.SDK_INT >= 21) {
                mediaViewLayoutHolder.mVideoFinishCoverImage.setImageTintMode(PorterDuff.Mode.SRC_OVER);
            }

            mediaViewLayoutHolder.mCoverTitle = view.findViewById(com.ss.android.article.browser.R.id.cover_title);
            mediaViewLayoutHolder.mVideoTime = view.findViewById(com.ss.android.article.browser.R.id.video_time);
            mediaViewLayoutHolder.mRLVideoEndCover = view.findViewById(com.ss.android.article.browser.R.id.rl_video_end_cover);
            mediaViewLayoutHolder.mIvShareWechat = view.findViewById(com.ss.android.article.browser.R.id.iv_share_platform_wechat);
            mediaViewLayoutHolder.mIvShareMoment = view.findViewById(com.ss.android.article.browser.R.id.iv_share_platform_moment);
            mediaViewLayoutHolder.mIvShareQQ = view.findViewById(com.ss.android.article.browser.R.id.iv_share_platform_qq);
            mediaViewLayoutHolder.mIvShareQzone = view.findViewById(com.ss.android.article.browser.R.id.iv_share_paltform_qzone);
            mediaViewLayoutHolder.mLLReplay = view.findViewById(com.ss.android.article.browser.R.id.ll_replay);
            mediaViewLayoutHolder.mAdActionLayout = view.findViewById(com.ss.android.article.browser.R.id.ad_action_layout);
            mediaViewLayoutHolder.mAdLeftTime = view.findViewById(com.ss.android.article.browser.R.id.ad_left_time);
            mediaViewLayoutHolder.mAdJumpBtn = view.findViewById(com.ss.android.article.browser.R.id.ad_jump_btn);
            mediaViewLayoutHolder.mAdLeftJumpLine = view.findViewById(com.ss.android.article.browser.R.id.ad_left_jump_line);
            mediaViewLayoutHolder.mVideoAdBottomLayout = view.findViewById(com.ss.android.article.browser.R.id.video_ad_bottom_layout);
            mediaViewLayoutHolder.mVideoAdGoDetailBottom = view.findViewById(com.ss.android.article.browser.R.id.video_ad_godetail_bottom);
            mediaViewLayoutHolder.mVideoAdFullscreen = view.findViewById(com.ss.android.article.browser.R.id.video_ad_full_screen);
            mediaViewLayoutHolder.mLargeButtonAd = view.findViewById(com.ss.android.article.browser.R.id.large_button_ad);
            mediaViewLayoutHolder.mAdSplashJumpBtn = view.findViewById(com.ss.android.article.browser.R.id.ad_splash_jump_btn);
            mediaViewLayoutHolder.mAdSplashIgnore = view.findViewById(com.ss.android.article.browser.R.id.ad_splash_ignore);
            mediaViewLayoutHolder.mAdSplashHasWifiLoaded = view.findViewById(com.ss.android.article.browser.R.id.ad_splash_has_wifi_loaded);
            mediaViewLayoutHolder.mAdSplashLogo = view.findViewById(com.ss.android.article.browser.R.id.ad_splash_logo);
            mediaViewLayoutHolder.mAdSplashSkipLoading = view.findViewById(com.ss.android.article.browser.R.id.ad_splash_skip_loading);
            mediaViewLayoutHolder.mVideoLiveBottomLayout = view.findViewById(com.ss.android.article.browser.R.id.video_live_bottom_layout);
            mediaViewLayoutHolder.mVideoLiveTip = view.findViewById(com.ss.android.article.browser.R.id.video_live_tip);
            mediaViewLayoutHolder.mVideoLiveFullScreen = view.findViewById(com.ss.android.article.browser.R.id.video_live_full_screen);
            mediaViewLayoutHolder.mVideoLiveCoverContainer = view.findViewById(com.ss.android.article.browser.R.id.video_live_cover_container);
            mediaViewLayoutHolder.mLiveVideoStatus = view.findViewById(com.ss.android.article.browser.R.id.live_video_status);
            mediaViewLayoutHolder.mVideoCoverBack = view.findViewById(com.ss.android.article.browser.R.id.video_cover_back);
            mediaViewLayoutHolder.mVideoLiveCoverBack = view.findViewById(com.ss.android.article.browser.R.id.video_live_cover_back);
            mediaViewLayoutHolder.mVideoActionControlAreaRight = view.findViewById(com.ss.android.article.browser.R.id.video_action_control_area_right);
            mediaViewLayoutHolder.mVideoAreaRight = view.findViewById(com.ss.android.article.browser.R.id.video_area_right);
            view.setTag(mediaViewLayoutHolder);
        } else {
            mediaViewLayoutHolder = (MediaViewLayoutHolder) view.getTag();
        }

        mVideoSurface = mediaViewLayoutHolder.mVideoSurface;
        mVideoBack = mediaViewLayoutHolder.mVideoBack;
        mIvWatermark = mediaViewLayoutHolder.mIvWatermark;
        mVideoClose = mediaViewLayoutHolder.mVideoClose;
        mVideoTopLayout = mediaViewLayoutHolder.mVideoTopLayout;
        mVideoFullscreenBack = mediaViewLayoutHolder.mVideoFullscreenBack;
        mVideoTitle = mediaViewLayoutHolder.mVideoTitle;
        mVideoFullscreenTitle = mediaViewLayoutHolder.mVideoFullscreenTitle;
        mVideoCurrentTime = mediaViewLayoutHolder.mVideoCurrentTime;
        mBatteryLevel = mediaViewLayoutHolder.mBatteryLevel;
        mVideoBottomLayout = mediaViewLayoutHolder.mVideoBottomLayout;
        mVideoPlay = mediaViewLayoutHolder.mVideoPlay;
        mVideoMoreIv = mediaViewLayoutHolder.mVideoMoreIv;
        mVideoItemFeedMoreDot = mediaViewLayoutHolder.mVideoItemFeedMoreDot;
        mVideoBottomBarBGIv = mediaViewLayoutHolder.mVideoBottomBarBGIv;
        mSeekBar = mediaViewLayoutHolder.mVideoSeekBar;
        mVideoProgress = mediaViewLayoutHolder.mVideoProgress;
        mVideoTimeLeftTime = mediaViewLayoutHolder.mVideoTimeLeftTime;
        mVideoTimePlay = mediaViewLayoutHolder.mVideoTimePlay;
        mMediaThirdParty = mediaViewLayoutHolder.mMediaThirdParty;
        mVideoLoadingRetryLayout = mediaViewLayoutHolder.mVideoLoadingRetryLayout;
        mVideoFullscreen = mediaViewLayoutHolder.mVideoFullscreen;
        mVideoLoadingProgress = mediaViewLayoutHolder.mVideoLoadingProgress;
        mVideoLoadingRetry = mediaViewLayoutHolder.mVideoLoadingRetry;
        mVideoRetry = mediaViewLayoutHolder.mVideoRetry;
        mVideoRetryDes = mediaViewLayoutHolder.mVideoRetryDes;
        mVideoCoverContainer = mediaViewLayoutHolder.mVideoCoverContainer;
        mVideoCoverImage = mediaViewLayoutHolder.mVideoCoverImage;
        mVideoCoverGoDetail = mediaViewLayoutHolder.mVideoCoverGoDetail;
        mVideoCoverReplay = mediaViewLayoutHolder.mVideoCoverReplay;
        mVideoAdGoDetail = mediaViewLayoutHolder.mVideoAdGoDetail;
        mVideoLoadingCover = mediaViewLayoutHolder.mVideoLoadingCover;
        mVideoLoadingCoverImage = mediaViewLayoutHolder.mVideoLoadingCoverImage;
        mVideoAutoPlayLayout = mediaViewLayoutHolder.mVideoAutoPlayLayout;
        mAutoPlayEndCover = mediaViewLayoutHolder.mAutoPlayEndCover;
        mTvAutoPlay = mediaViewLayoutHolder.mAutoPlayEndCoverTvAutoPlay;
        mAutoPlayEndCoverTvVideoTitle = mediaViewLayoutHolder.mAutoPlayEndCoverTvVideoTitle;
        mAutoPlayEndCoverVideoEndCoverImageIv = mediaViewLayoutHolder.mAutoPlayEndCoverVideoEndCoverImageIv;
        mTvCancelAutoPlay = mediaViewLayoutHolder.mAutoPlayTvCancelAutoPlay;
        mFullscreenAutoPlayEndCover = mediaViewLayoutHolder.mFullscreenAutoPlayEndCover;
        mFullscreenAutoPlayEndCoverTvAutoPlay = mediaViewLayoutHolder.mFullscreenAutoPlayEndCoverTvAutoPlay;
        mFullscreenAutoPlayEndCoverTvVideoTitle = mediaViewLayoutHolder.mFullscreenAutoPlayEndCoverTvVideoTitle;
        mFullscreenAutoPlayEndCoverVideoEndCoverImageIv = mediaViewLayoutHolder.mFullscreenAutoPlayEndCoverVideoEndCoverImageIv;
        mFullscreenAutoPlayEndCoverTvCancelAutoPlay = mediaViewLayoutHolder.mFullscreenAutoPlayEndCoverTvCancelAutoPlay;
        mFinishInfoLayout = mediaViewLayoutHolder.mFinishInfoLayout;
        mVideoFollowCompleteReplay = mediaViewLayoutHolder.mVideoFollowCompleteReplay;
        mVideoFollowCompleteShare = mediaViewLayoutHolder.mVideoFollowCompleteShare;
        mVideoFinishCoverImage = mediaViewLayoutHolder.mVideoFinishCoverImage;
        mCoverTitle = mediaViewLayoutHolder.mCoverTitle;
        mVideoTime = mediaViewLayoutHolder.mVideoTime;
        mRLVideoEndCover = mediaViewLayoutHolder.mRLVideoEndCover;
        mIvShareWechat = mediaViewLayoutHolder.mIvShareWechat;
        mIvShareMoment = mediaViewLayoutHolder.mIvShareMoment;
        mIvShareQQ = mediaViewLayoutHolder.mIvShareQQ;
        mIvShareQzone = mediaViewLayoutHolder.mIvShareQzone;
        mLLReplay = mediaViewLayoutHolder.mLLReplay;
        mAdActionLayout = mediaViewLayoutHolder.mAdActionLayout;
        mAdLeftTime = mediaViewLayoutHolder.mAdLeftTime;
        mAdJumpBtn = mediaViewLayoutHolder.mAdJumpBtn;
        mAdLeftJumpLine = mediaViewLayoutHolder.mAdLeftJumpLine;
        mVideoAdBottomLayout = mediaViewLayoutHolder.mVideoAdBottomLayout;
        mVideoAdGoDetailBottom = mediaViewLayoutHolder.mVideoAdGoDetailBottom;
        mVideoAdFullscreen = mediaViewLayoutHolder.mVideoAdFullscreen;
        mLargeButtonAd = mediaViewLayoutHolder.mLargeButtonAd;
        mAdSplashJumpBtn = mediaViewLayoutHolder.mAdSplashJumpBtn;
        mAdSplashIgnore = mediaViewLayoutHolder.mAdSplashIgnore;
        mAdSplashHasWifiLoaded = mediaViewLayoutHolder.mAdSplashHasWifiLoaded;
        mAdSplashIgnore.setWillNotDraw(false);
        mAdSplashLogo = mediaViewLayoutHolder.mAdSplashLogo;
        mAdSplashSkipLoading = mediaViewLayoutHolder.mAdSplashSkipLoading;
        mVideoLiveBottomLayout = mediaViewLayoutHolder.mVideoLiveBottomLayout;
        mVideoLiveTip = mediaViewLayoutHolder.mVideoLiveTip;
        mVideoLiveTip.a();
        mVideoLiveFullScreen = mediaViewLayoutHolder.mVideoLiveFullScreen;
        mVideoLiveCoverContainer = mediaViewLayoutHolder.mVideoLiveCoverContainer;
        mLiveVideoStatus = mediaViewLayoutHolder.mLiveVideoStatus;
        mVideoCoverBack = mediaViewLayoutHolder.mVideoCoverBack;
        mVideoLiveCoverBack = mediaViewLayoutHolder.mVideoLiveCoverBack;
        mVideoActionControlAreaRight = mediaViewLayoutHolder.mVideoActionControlAreaRight;
        mVideoAreaRight = mediaViewLayoutHolder.mVideoAreaRight;
    }

    private void showAutoPlayEndCover(Article article) {
        if (this.nonNullCallback() && mContext != null && article != null) {
            if (this.bW && this.isCellType) {
                mWeakHandler.removeCallbacks(mEndCoverCountdownRunnable);
                UIUtils.setVisibility(mVideoBack, View.GONE);
                this.bW = false;
                return;
            }

            if (this.bW && !this.isCellType) {
                this.bW = false;
                mWeakHandler.removeCallbacks(mEndCoverCountdownRunnable);
                mAutoPlayDelaySeconds = 0;
            }

            if ((this.isCellType) && !this.isFullScreen()) {
                return;
            }

            if (!AppData.getInstance().getAbSettings().isFullScreenAutoPlayNext()) {
                this.disableAutoRotate();
            } else if (this.callback.isCurrentVideoAutoRotatable()) {
                this.enableAutoRotate();
            }

            UIUtils.setVisibility(mVideoCoverContainer, View.GONE);
            this.dismissToolBar(false, true);
            if (this.isCellType) {
                UIUtils.setVisibility(mVideoBack, View.GONE);
            } else {
                UIUtils.setVisibility(mVideoBack, 0);
            }

            UIUtils.setVisibility(mFullscreenAutoPlayEndCover, View.GONE);
            UIUtils.setVisibility(mAutoPlayEndCover, 0);
            ImageInfo imageInfo = null;
            if (article == null) {
                return;
            }

            if (article.mLoadingCoverImageInfo != null) {
                imageInfo = article.mLoadingCoverImageInfo;
            }

            int screenWidth = mContext.getResources().getDisplayMetrics().widthPixels;
            int screenHeight = mContext.getResources().getDisplayMetrics().heightPixels;
            if (screenWidth <= screenHeight) {
                screenHeight = screenWidth;
            }
            int itemImageTotalPadding = mContext.getResources().getDimensionPixelOffset(com.ss.android.article.browser.R.dimen.item_image_total_padding);
            int itemImageWidth = (screenHeight - itemImageTotalPadding) / 3;
            setLayout(mAutoPlayEndCoverVideoEndCoverImageIv, itemImageWidth, itemImageWidth * 9 / 16);
            android.support.design.a.setImage(mAutoPlayEndCoverVideoEndCoverImageIv, imageInfo);
            UIUtils.setText(mAutoPlayEndCoverTvVideoTitle, article.title);
            String autoPlayText = mAutoPlayDelaySeconds == 0
                    ? mContext.getString(com.ss.android.article.browser.R.string.next_video)
                    : mAutoPlayDelaySeconds + mContext.getString(com.ss.android.article.browser.R.string.after_x_seconds_auto_play);
            int length = autoPlayText.length();
            SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(autoPlayText);
            ForegroundColorSpan delayForegroundColor = new ForegroundColorSpan(mContext.getResources().getColor(com.ss.android.article.browser.R.color.ssxinzi4));
            ForegroundColorSpan autoPlayTextForegroundColor = new ForegroundColorSpan(mContext.getResources().getColor(com.ss.android.article.browser.R.color.cg));
            if (mAutoPlayDelaySeconds == 0) {
                spannableStringBuilder.setSpan(autoPlayTextForegroundColor, 0, length, 33);
            } else {
                spannableStringBuilder.setSpan(delayForegroundColor, 0, 1, 33);
                spannableStringBuilder.setSpan(autoPlayTextForegroundColor, 1, length, 33);
            }
            UIUtils.setText(mTvAutoPlay, spannableStringBuilder);
            UIUtils.setText(mTvCancelAutoPlay, mContext.getString(com.ss.android.article.browser.R.string.cancel_auto_play));
        }
    }

    private void a(Boolean arg3) {
        if (arg3.booleanValue()) {
            mMediaRoot.setSystemUiVisibility(0);
        } else if (Q >= 19) {
            mMediaRoot.setSystemUiVisibility(3334);
        } else if (Q >= 16) {
            mMediaRoot.setSystemUiVisibility(5);
        } else {
            mMediaRoot.setSystemUiVisibility(1);
        }
    }

    public final void onOrientationChanged(int screenOrientation) {
        if (AppData.getInstance().isVideoAccelerated() && this.isAutoRotateEnabled) {
            if (screenOrientation != -1 && screenOrientation != 9) {
                int screenRotation = this.getScreenRotation();
                if (screenOrientation == screenRotation) {
                    mWeakHandler.removeMessages(2);
                } else {
                    int v2 = 1;
                    if (Settings.System.getInt(this.L.mContext.getContentResolver(), "accelerometer_rotation", 0) != 1) {
                        v2 = 0;
                    }
                    if (v2 == 0) {
                        if (screenRotation != 0 && screenRotation != 8) {
                            return;
                        }

                        if (screenOrientation == 0) {

                        } else if (screenOrientation != 8) {
                            return;
                        }
                    }
                    mWeakHandler.removeMessages(2);
                    long v0 = 500;
                    if (SystemClock.uptimeMillis() - mSurfaceChangedTime >= v0) {
                        v0 = 0;
                    }
                    mSurfaceChangedTime = SystemClock.uptimeMillis();
                    mWeakHandler.sendMessageDelayed(Message.obtain(mWeakHandler, 2, screenOrientation, 0), v0);
                    this.cf = screenOrientation;
                }
                return;
            }
            mWeakHandler.removeMessages(2);
        }
    }

    public final void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture) {
        this.isSurfaceCreated = true;
        if (this.nonNullCallback()) {
            this.callback.textureViewCreated(this, new Surface(surfaceTexture));
        }
    }

    public final void surfaceCreated(SurfaceHolder surfaceHolder) {
        mWeakHandler.removeMessages(2);
        if (surfaceHolder == mVideoSurface.getHolder()) {
            this.isSurfaceCreated = true;
            if (this.nonNullCallback()) {
                this.callback.surfaceCreated(this, surfaceHolder);
            }
        }
    }

    public final void surfaceChanged(SurfaceHolder surfaceHolder, int format, int width, int height) {
        mSurfaceChangedTime = SystemClock.uptimeMillis();
        if (mWeakHandler.hasMessages(2)) {
            mWeakHandler.removeMessages(2);
            if (this.cf != -1) {
                mWeakHandler.sendMessageDelayed(Message.obtain(mWeakHandler, 2, this.cf, 0), 500);
                this.cf = -1;
            }
        }

        if (surfaceHolder == mVideoSurface.getHolder() && (this.nonNullCallback())) {
            this.callback.surfaceChanged(this, surfaceHolder, format, width, height);
        }
    }

    public final int getVolume() {
        return mVolumeProgressBar != null ? mVolumeProgressBar.getProgress() : -1;
    }

    private void setVideoMoreIvVisible(int visibility) {
        if (!AppData.getInstance().getAbSettings().isVideoFragmentShare()
                && !AppData.getInstance().getAbSettings().isBottomShare()) {
            mVideoMoreIv.setVisibility(View.GONE);
            mVideoBottomBarBGIv.setVisibility(View.GONE);
        } else if (!this.isCellType()) {
            mVideoMoreIv.setVisibility(visibility);
            mVideoBottomBarBGIv.setVisibility(visibility);
        } else {
            mVideoMoreIv.setVisibility(View.GONE);
            mVideoBottomBarBGIv.setVisibility(View.GONE);
        }
    }

    private void showFullscreenAutoPlayEndCover(Article article) {
        if ((this.nonNullCallback()) && mContext != null) {
            if (this.callback.isCurrentVideoAutoRotatable()) {
                this.enableAutoRotate();
            }

            UIUtils.setVisibility(mVideoCoverContainer, View.GONE);
            this.dismissToolBar(false, true);
            UIUtils.setVisibility(mAutoPlayEndCover, View.GONE);
            UIUtils.setVisibility(mFullscreenAutoPlayEndCover, 0);
            UIUtils.setVisibility(mVideoBack, 0);
            ImageInfo imageInfo = null;
            if (article == null) {
                return;
            }
            if (article.mLoadingCoverImageInfo != null) {
                imageInfo = article.mLoadingCoverImageInfo;
            }
            int screenWidth = mContext.getResources().getDisplayMetrics().widthPixels;
            int screenHeight = mContext.getResources().getDisplayMetrics().heightPixels;
            if (screenWidth <= screenHeight) {
                screenHeight = screenWidth;
            }
            screenHeight = (screenHeight - mContext.getResources().getDimensionPixelOffset(com.ss.android.article.browser.R.dimen.item_image_total_padding)) / 3;
            setLayout(mFullscreenAutoPlayEndCoverVideoEndCoverImageIv, screenHeight << 1, screenHeight * 9 / 16 << 1);
            android.support.design.a.setImage(mFullscreenAutoPlayEndCoverVideoEndCoverImageIv, imageInfo);
            UIUtils.setText(mFullscreenAutoPlayEndCoverTvVideoTitle, article.title);
            String autoPlayTxt = mAutoPlayDelaySeconds + mContext.getString(com.ss.android.article.browser.R.string.after_x_seconds_auto_play);
            if (mAutoPlayDelaySeconds == 0) {
                autoPlayTxt = mContext.getString(com.ss.android.article.browser.R.string.next_video);
            }

            int length = autoPlayTxt.length();
            SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(autoPlayTxt);
            ForegroundColorSpan countdownColor = new ForegroundColorSpan(mContext.getResources().getColor(com.ss.android.article.browser.R.color.ssxinzi4));
            ForegroundColorSpan txtColor = new ForegroundColorSpan(mContext.getResources().getColor(com.ss.android.article.browser.R.color.cg));
            if (mAutoPlayDelaySeconds == 0) {
                spannableStringBuilder.setSpan(txtColor, 0, length, 33);
            } else {
                spannableStringBuilder.setSpan(countdownColor, 0, 1, 33);
                spannableStringBuilder.setSpan(txtColor, 1, length, 33);
            }
            UIUtils.setText(mFullscreenAutoPlayEndCoverTvAutoPlay, spannableStringBuilder);
            UIUtils.setText(mFullscreenAutoPlayEndCoverTvCancelAutoPlay, mContext.getString(com.ss.android.article.browser.R.string.cancel_auto_play));
        }
    }

    private void adaptFullscreenChanged(boolean isFullscreen) {
        if (isFullscreen) {
            DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics();
            this.setVideoItemFeedMoreDotVisible(View.VISIBLE);
            this.setVideoMoreIvVisible(View.GONE);
            if (mVideoTimePlay != null) {
                mLastVideoTimePlayTextSize = mVideoTimePlay.getTextSize();
                mVideoTimePlay.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f);
                mLastVideoTimePlayTextColor = mVideoTimePlay.getTextColors();
                if (mLastVideoTimePlayTextColor != null) {
                    mVideoTimePlay.setTextColor(mContext.getResources().getColor(com.ss.android.article.browser.R.color.uv));
                }
                mLastVideoTimePlayAlpha = mVideoTimePlay.getAlpha();
                mVideoTimePlay.setAlpha(0.85f);
                ViewGroup.LayoutParams layoutParams = mVideoTimePlay.getLayoutParams();
                if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
                    ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) layoutParams;
                    mShrinkVideoTimePlayMargins.set(lp.leftMargin, lp.topMargin, lp.rightMargin, lp.bottomMargin);
                    UIUtils.setLayoutMargins(mVideoTimePlay,
                            (int) TypedValue.applyDimension(1, 16f, displayMetrics),
                            mShrinkVideoTimePlayMargins.top,
                            (int) TypedValue.applyDimension(1, 16f, displayMetrics),
                            mShrinkVideoTimePlayMargins.bottom);
                }
            }

            if (mVideoTimeLeftTime != null) {
                mLastVideoTimeLeftTimeTextSize = mVideoTimeLeftTime.getTextSize();
                mVideoTimeLeftTime.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f);
                mLastVideoTimeLeftTimeTextColor = mVideoTimeLeftTime.getTextColors();
                if (mLastVideoTimeLeftTimeTextColor != null) {
                    mVideoTimeLeftTime.setTextColor(mContext.getResources().getColor(com.ss.android.article.browser.R.color.uv));
                }
                mLastVideoTimeLeftTimeAlpha = mVideoTimeLeftTime.getAlpha();
                mVideoTimeLeftTime.setAlpha(0.85f);
                ViewGroup.LayoutParams layoutParams = mVideoTimeLeftTime.getLayoutParams();
                if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
                    ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) layoutParams;
                    mShrinkVideoTimeLeftTimeMargins.set(lp.leftMargin, lp.topMargin, lp.rightMargin, lp.bottomMargin);
                    UIUtils.setLayoutMargins(mVideoTimeLeftTime,
                            (int) TypedValue.applyDimension(1, 16f, displayMetrics),
                            mShrinkVideoTimeLeftTimeMargins.top,
                            mShrinkVideoTimeLeftTimeMargins.right,
                            mShrinkVideoTimeLeftTimeMargins.bottom);
                }
            }

            if (mVideoFullscreen != null) {
                mVideoFullscreen.setImageResource(com.ss.android.article.browser.R.drawable.media_full_player_icon);
            }

            if (mVideoAdFullscreen != null) {
                mVideoAdFullscreen.setImageResource(com.ss.android.article.browser.R.drawable.media_full_player_icon);
            }

            if (mVideoLiveFullScreen != null) {
                mVideoLiveFullScreen.setImageResource(com.ss.android.article.browser.R.drawable.media_full_player_icon);
            }

            if (mIvWatermark != null) {
                UIUtils.setLayoutMargins(mIvWatermark,
                        -3,
                        ((int) UIUtils.dp2px(mContext, 35f)),
                        ((int) UIUtils.dp2px(mContext, 20f)), -3);
            }

            if (mVideoBottomLayout != null) {
                ViewGroup.LayoutParams layoutParams = mVideoBottomLayout.getLayoutParams();
                mPotraitVideoBottomLayoutHeight = layoutParams.height;
                layoutParams.height = ((int) TypedValue.applyDimension(1, 49f, displayMetrics));
                mVideoBottomLayout.setLayoutParams(layoutParams);
                mVideoBottomLayout.setBackgroundResource(com.ss.android.article.browser.R.drawable.io);
            }

            if (mVideoFullscreenTitle != null) {
                mShrinkVideoFullscreenTitleTextColor = mVideoFullscreenTitle.getTextColors();
                if (mShrinkVideoFullscreenTitleTextColor != null) {
                    mVideoFullscreenTitle.setTextColor(mContext.getResources().getColor(com.ss.android.article.browser.R.color.uv));
                }

                mShrinkVideoFullscreenTitleAlpha = mVideoFullscreenTitle.getAlpha();
                mVideoFullscreenTitle.setAlpha(0.85f);
                ViewGroup.LayoutParams layoutParams = mVideoFullscreenTitle.getLayoutParams();
                if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
                    ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) layoutParams;
                    this.mFullscreenTitleMargins.set(lp.leftMargin, lp.topMargin, lp.rightMargin, lp.bottomMargin);
                    UIUtils.setLayoutMargins(mVideoFullscreenTitle,
                            (int) TypedValue.applyDimension(1, 1f, displayMetrics),
                            mShrinkVideoTimeLeftTimeMargins.top,
                            mShrinkVideoTimeLeftTimeMargins.right,
                            mShrinkVideoTimeLeftTimeMargins.bottom);
                }
            }

            if (mVideoTopLayout != null) {
                ViewGroup.LayoutParams layoutParams = mVideoTopLayout.getLayoutParams();
                mShrinkVideoTopLayoutHeight = layoutParams.height;
                layoutParams.height = ((int) TypedValue.applyDimension(1, 49f, displayMetrics));
                mVideoTopLayout.setLayoutParams(layoutParams);
                mVideoTopLayout.setBackgroundResource(com.ss.android.article.browser.R.drawable.ip);
            }

            this.setPlayIcon(this.bJ, this.isLiveVideo);
        } else {
            this.setVideoItemFeedMoreDotVisible(View.GONE);
            this.setVideoMoreIvVisible(View.VISIBLE);
            if (mVideoTimePlay != null) {
                mVideoTimePlay.setTextSize(0, mLastVideoTimePlayTextSize);
                if (mLastVideoTimePlayTextColor != null) {
                    mVideoTimePlay.setTextColor(mLastVideoTimePlayTextColor);
                }

                mVideoTimePlay.setAlpha(mLastVideoTimePlayAlpha);
                UIUtils.setLayoutMargins(mVideoTimePlay,
                        mShrinkVideoTimePlayMargins.left,
                        mShrinkVideoTimePlayMargins.top,
                        mShrinkVideoTimePlayMargins.right,
                        mShrinkVideoTimePlayMargins.bottom);
            }

            if (mVideoTimeLeftTime != null) {
                mVideoTimeLeftTime.setTextSize(0, mLastVideoTimeLeftTimeTextSize);
                if (mLastVideoTimeLeftTimeTextColor != null) {
                    mVideoTimeLeftTime.setTextColor(mLastVideoTimeLeftTimeTextColor);
                }

                mVideoTimeLeftTime.setAlpha(mLastVideoTimeLeftTimeAlpha);
                UIUtils.setLayoutMargins(mVideoTimeLeftTime, mShrinkVideoTimeLeftTimeMargins.left, mShrinkVideoTimeLeftTimeMargins.top, mShrinkVideoTimeLeftTimeMargins.right, mShrinkVideoTimeLeftTimeMargins.bottom);
            }

            if (mVideoFullscreen != null) {
                mVideoFullscreen.setImageResource(com.ss.android.article.browser.R.drawable.enlarge_video);
            }

            if (mVideoAdFullscreen != null) {
                mVideoAdFullscreen.setImageResource(com.ss.android.article.browser.R.drawable.enlarge_video);
            }

            if (mVideoLiveFullScreen != null) {
                mVideoLiveFullScreen.setImageResource(com.ss.android.article.browser.R.drawable.enlarge_video);
            }

            if (mVideoBottomLayout != null) {
                ViewGroup.LayoutParams layoutParams = mVideoBottomLayout.getLayoutParams();
                layoutParams.height = mPotraitVideoBottomLayoutHeight;
                mVideoBottomLayout.setLayoutParams(layoutParams);
                mVideoBottomLayout.setBackgroundResource(com.ss.android.article.browser.R.color.video_player_bottom_bg_color);
            }

            if (mVideoFullscreenTitle != null) {
                if (mShrinkVideoFullscreenTitleTextColor != null) {
                    mVideoFullscreenTitle.setTextColor(mShrinkVideoFullscreenTitleTextColor);
                }

                mVideoFullscreenTitle.setAlpha(mShrinkVideoFullscreenTitleAlpha);
                UIUtils.setLayoutMargins(mVideoFullscreenTitle, mShrinkVideoTimeLeftTimeMargins.left, mShrinkVideoTimeLeftTimeMargins.top, mShrinkVideoTimeLeftTimeMargins.right, mShrinkVideoTimeLeftTimeMargins.bottom);
            }

            if (mIvWatermark != null) {
                UIUtils.setLayoutMargins(mIvWatermark,
                        -3,
                        ((int) UIUtils.dp2px(mContext, 20f)),
                        ((int) UIUtils.dp2px(mContext, 15f)),
                        -3);
            }

            if (mVideoTopLayout != null) {
                ViewGroup.LayoutParams layoutParams = mVideoTopLayout.getLayoutParams();
                layoutParams.height = mShrinkVideoTopLayoutHeight;
                mVideoTopLayout.setLayoutParams(layoutParams);
                mVideoTopLayout.setBackgroundResource(com.ss.android.article.browser.R.drawable.black_desc_gradient);
            }

            this.setPlayIcon(this.bJ, this.isLiveVideo);
            if (!this.isFullscreenAutoPlayEndCoverVisible()) {
                return;
            }
            UIUtils.setVisibility(mFullscreenAutoPlayEndCover, View.GONE);
            this.bW = true;
            if (this.isCellType) {
                this.disableAutoRotate();
                this.showNewCover(mArticle);
            }
            this.showAutoPlayEndCover(mNextVideoArticle);
        }
    }

    public final void surfaceDestroyed(SurfaceHolder surfaceHolder) {
        mWeakHandler.removeMessages(2);
        if (mBatteryChangedReceiver != null) {
            try {
                mContext.unregisterReceiver(mBatteryChangedReceiver);
                mBatteryChangedReceiver = null;
            } catch (Exception exception) {
                exception.printStackTrace();
            }
        }

        if (surfaceHolder == mVideoSurface.getHolder()) {
            this.isSurfaceCreated = false;
            if (this.nonNullCallback()) {
                this.callback.surfaceDestroyed(this, surfaceHolder);
            }
        }
    }

    private void setVideoItemFeedMoreDotVisible(int visibility) {
        if (AppData.getInstance().getAbSettings().isVideoFragmentShare()
                || AppData.getInstance().getAbSettings().isBottomShare()) {
            mVideoItemFeedMoreDot.setVisibility(visibility);
        } else {
            mVideoItemFeedMoreDot.setVisibility(View.GONE);
        }
    }

    public final boolean onSurfaceTextureDestroyed() {
        this.isSurfaceCreated = false;
        return false;
    }

    public final void clearView() {
        mVolumeDialog = null;
        mVolumeProgressBar = null;
        mVideoProgressDialog = null;
        mDurationProgressBar = null;
        mDurationImageTip = null;
        mTvCurrent = null;
        mTvDuration = null;
        mDialog = null;
    }

    final boolean isAutoPlayEndCoverVisible() {
        return mAutoPlayEndCover != null && mAutoPlayEndCover.getVisibility() == View.VISIBLE;
    }

    public final void disableAutoRotate() {
        if (this.isAutoRotateEnabled) {
            this.isAutoRotateEnabled = false;
            mWeakHandler.removeMessages(2);
            this.L.mMyOrientationEventListener.disable();
            this.L.reset();
            ScreenOrientationObserver v0 = this.L;
            if (this != null) {
                v0.mOrientationChangeListenerSet.remove(this);
            }
        }
    }

    public final void dismissAllEndCover() {
        mAutoPlayDelaySeconds = 0;
        mWeakHandler.removeCallbacks(mEndCoverCountdownRunnable);
        this.disableAutoRotate();
        if (this.isCellType) {
            UIUtils.setVisibility(mVideoBack, View.GONE);
        }
        UIUtils.setVisibility(mAutoPlayEndCover, View.GONE);
        UIUtils.setVisibility(mFullscreenAutoPlayEndCover, View.GONE);
    }

    public final void dismissCover() {
        UIUtils.setVisibility(mVideoCoverContainer, View.GONE);
    }

    public final void dismissLoading() {
        mVideoLoadingRetryLayout.setVisibility(View.GONE);
        mVideoLoadingProgress.setVisibility(View.GONE);
    }

    public final void dismissLoadingCover() {
        UIUtils.setVisibility(mVideoLoadingCover, View.GONE);
    }

    public final void dismissMediaPlayer() {
        this.setVisibility(View.GONE);
    }

    public final void dismissNewCover() {
        if (AppData.getInstance().getAbSettings().isVideoPlayerShare()) {
            UIUtils.setVisibility(mRLVideoEndCover, View.GONE);
        } else {
            UIUtils.setVisibility(mFinishInfoLayout, View.GONE);
        }
    }

    public final boolean dismissNoWifiNoticeDialog() {
        try {
            if (mDialog == null) {
                return false;
            }
            if (!mDialog.isShowing()) {
                return false;
            }
            mDialog.dismiss();
            return true;
        } catch (Exception v0) {
        }

        return false;
    }

    public final void dismissRetry() {
        mVideoLoadingRetryLayout.setVisibility(View.GONE);
        mVideoLoadingRetry.setVisibility(View.GONE);
    }

    public final void dismissToolBar() {
        this.dismissToolBar(true, false);
    }

    public final void dismissToolBar(boolean videoProgressVisible, boolean arg6) {
        if (this.isDirectPlay) {
            mVideoBottomLayout.setVisibility(View.GONE);
            mVideoProgress.setVisibility(View.GONE);
        } else {
            if (this.isFullScreen()) {
                this.a(Boolean.valueOf(false));
            }

            mVideoLiveBottomLayout.setVisibility(View.GONE);
            mVideoTopLayout.setVisibility(View.GONE);
            this.setVideoMoreIvVisible(View.GONE);
            mVideoBottomLayout.setVisibility(View.GONE);
            mVideoProgress.setVisibility(videoProgressVisible ? View.VISIBLE : View.GONE);
            mVideoPlay.setVisibility(View.GONE);
            if (!this.isCellType && !this.isFullscreen) {
                mVideoClose.setVisibility(View.GONE);
                if (!this.bV.contains(CtrlFlag.alwayShowBackBtn)) {
                    mVideoBack.setVisibility(View.GONE);
                }
            } else if (this.bV.contains(CtrlFlag.hideCloseBtn)) {
                UIUtils.setVisibility(mVideoClose, View.GONE);
            }

            if (arg6) {
                UIUtils.setVisibility(mVideoClose, View.GONE);
                UIUtils.setVisibility(mVideoBack, View.GONE);
            }
            this.trySetTitleVisiable(false);
            mMediaThirdParty.setVisibility(View.GONE);
        }
    }

    public final boolean dismissTouchProgress() {
        try {
            if (mVideoProgressDialog == null) {
                return false;
            }

            if (!mVideoProgressDialog.isShowing()) {
                return false;
            }

            mVideoProgressDialog.dismiss();
            boolean v0_1 = true;
            return v0_1;
        } catch (Exception v0) {
        }

        return false;
    }

    public final boolean dismissVolume() {
        try {
            if (mVolumeDialog == null) {
                return false;
            }

            if (!mVolumeDialog.isShowing()) {
                return false;
            }
            mVolumeDialog.dismiss();
            return true;
        } catch (Exception exception) {
        }
        return false;
    }

    final boolean isFullscreenAutoPlayEndCoverVisible() {
        return mFullscreenAutoPlayEndCover != null && mFullscreenAutoPlayEndCover.getVisibility() == View.VISIBLE;
    }

    public final void enableAutoRotate() {
        if (!this.isAutoRotateEnabled && (AppData.getInstance().isVideoAccelerated())) {
            this.isAutoRotateEnabled = true;
            ScreenOrientationObserver v0 = this.L;
            if (this != null) {
                v0.mOrientationChangeListenerSet.add(this);
            }

            this.L.reset();
            this.L.mMyOrientationEventListener.enable();
        }
    }

    public final void enterFullScreen(ViewGroup viewGroup) {
        this.isFullscreen = true;
        if ((mMediaRoot.getLayoutParams() instanceof ViewGroup.MarginLayoutParams)) {
            ViewGroup.LayoutParams layoutParams = mMediaRoot.getLayoutParams();
            if (!this.isDetailAutoPlayKeepFullScreen) {
                mPortraitLeftMargin = ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin;
                mPortraitTopMargin = ((ViewGroup.MarginLayoutParams) layoutParams).topMargin;
                mPortraitWidth = ((ViewGroup.MarginLayoutParams) layoutParams).width;
                mPortraitHeight = ((ViewGroup.MarginLayoutParams) layoutParams).height;
            }

            ((ViewGroup.MarginLayoutParams) layoutParams).width = MATCH_PARENT;
            ((ViewGroup.MarginLayoutParams) layoutParams).height = MATCH_PARENT;
            ((ViewGroup.MarginLayoutParams) layoutParams).topMargin = 0;
            ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin = 0;
            mMediaRoot.setLayoutParams(layoutParams);
            ViewGroup.LayoutParams v1 = viewGroup.getLayoutParams();
            if ((v1 instanceof RelativeLayout.LayoutParams)) {
                layoutParams = v1;
                int[] v2_1 = ((RelativeLayout.LayoutParams) layoutParams).getRules();
                mPortraitRule = v2_1.length > 0 ? v2_1[3] : 0;
                ((RelativeLayout.LayoutParams) layoutParams).addRule(3, 0);
                viewGroup.setLayoutParams(layoutParams);
            }

            if ((v1 instanceof ViewGroup.MarginLayoutParams)) {
                mPotraitMargins.set(((ViewGroup.MarginLayoutParams) v1).leftMargin, ((ViewGroup.MarginLayoutParams) v1).topMargin,
                        ((ViewGroup.MarginLayoutParams) v1).rightMargin, ((ViewGroup.MarginLayoutParams) v1).bottomMargin);
                UIUtils.setLayoutMargins(((View) viewGroup), 0, 0, 0, 0);
            }

            this.setPlayerSurfaceViewSize(true);
            mVideoFullscreen.setImageResource(com.ss.android.article.browser.R.drawable.shrink_video);
            mVideoAdFullscreen.setImageResource(com.ss.android.article.browser.R.drawable.shrink_video);
            mVideoLiveFullScreen.setImageResource(com.ss.android.article.browser.R.drawable.shrink_video);
            this.a(Boolean.valueOf(false));
            this.adaptFullscreenChanged(this.isFullscreen);
            if (!this.isDetailAutoPlayKeepFullScreen) {
                this.adaptFullscreenChanged(this.isFullscreen);
            }

            mVideoTopLayout.setVisibility(View.GONE);
            if (!this.isCellType) {
                mVideoClose.setVisibility(View.GONE);
                mVideoBack.setVisibility(View.GONE);
            } else if (this.bV.contains(CtrlFlag.hideCloseBtn)) {
                UIUtils.setVisibility(mVideoClose, View.GONE);
            }

            if (AppData.getInstance().getAbSettings().isVideoMultiResolutionEnabled()) {
                if (!this.callback.isAd()) {
                    try {
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("num", this.q);
                        MobClickCombiner.onEvent(mContext, "video", "clarity_show", this.getGroupId(), 0, jsonObject);
                    } catch (JSONException jsonException) {
                    }

                    mVideoActionControlAreaRight.setVisibility(View.VISIBLE);
                } else {
                    mVideoActionControlAreaRight.setVisibility(View.GONE);
                }
            }

            this.isDetailAutoPlayKeepFullScreen = false;
            if (this.nonNullCallback()) {
                VideoAutoPlayHelperDetail videoAutoPlayHelperDetail = this.callback.getVideoAutoPlayHelperDetail();
                if (videoAutoPlayHelperDetail != null) {
                    videoAutoPlayHelperDetail.a(this.isFullscreen, this.isCellType, this.isLiveVideo, this.J);
                }
            }
        }
    }

    public final void exitFullScreen(ViewGroup viewGroup) {
        int expandDrawableResId = com.ss.android.article.browser.R.drawable.enlarge_video;
        if (mMediaRoot != null && ((mMediaRoot.getLayoutParams() instanceof ViewGroup.MarginLayoutParams))) {
            this.isDetailAutoPlayKeepFullScreen = false;
            this.translatioXVideoAreaRight(false);
            this.isFullscreen = false;
            ViewGroup.LayoutParams layoutParams = mMediaRoot.getLayoutParams();
            layoutParams.width = mPortraitWidth;
            layoutParams.height = mPortraitHeight;
            ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin = mPortraitLeftMargin;
            ((ViewGroup.MarginLayoutParams) layoutParams).topMargin = mPortraitTopMargin;
            if ((AppData.getInstance().getAbSettings().isPersistVivoMultiWindow()) && (getVivoMultiWindowActive())) {
                Display display = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
                if (display.getHeight() * display.getWidth() != mLastWidth * mLastHeight) {
                    layoutParams.width = mLastWidth;
                }
            }
            mMediaRoot.setLayoutParams(layoutParams);
            ViewGroup.LayoutParams params = viewGroup.getLayoutParams();
            if ((params instanceof RelativeLayout.LayoutParams)) {
                ((RelativeLayout.LayoutParams) params).addRule(3, mPortraitRule);
                viewGroup.setLayoutParams(params);
            }

            if ((params instanceof ViewGroup.MarginLayoutParams)) {
                UIUtils.setLayoutMargins(((View) viewGroup), mPotraitMargins.left, mPotraitMargins.top, mPotraitMargins.right, mPotraitMargins.bottom);
            }

            this.setPlayerSurfaceViewSize(true);
            mVideoFullscreen.setImageResource(expandDrawableResId);
            mVideoAdFullscreen.setImageResource(expandDrawableResId);
            mVideoLiveFullScreen.setImageResource(expandDrawableResId);
            this.a(Boolean.TRUE);
            this.adaptFullscreenChanged(this.isFullscreen);
            mVideoTopLayout.setVisibility(View.GONE);
            if (!this.isCellType && mVideoBottomLayout != null && mVideoBottomLayout.getVisibility() == View.VISIBLE) {
                if (!this.bV.contains(CtrlFlag.hideCloseBtn)) {
                    mVideoClose.setVisibility(View.VISIBLE);
                }

                mVideoBack.setVisibility(View.VISIBLE);
            }

            if (this.bV.contains(CtrlFlag.alwayShowBackBtn)) {
                mVideoBack.setVisibility(View.VISIBLE);
            }

            mVideoActionControlAreaRight.setVisibility(View.GONE);
            if (!this.nonNullCallback()) {
                return;
            }

            VideoAutoPlayHelperDetail videoAutoPlayHelperDetail = this.callback.getVideoAutoPlayHelperDetail();
            if (videoAutoPlayHelperDetail == null) {
                return;
            }
            videoAutoPlayHelperDetail.a(this.isFullscreen, this.isCellType, this.isLiveVideo, this.J);
        }
    }

    final long getGroupId() {
        return this.callback != null ? this.callback.getGroupId() : 0;
    }

    private void bindListener() {
        mVideoSurface.setRenderCallback(this);
        if ((AppData.getInstance().getAbSettings().isPersistVivoMultiWindow()) && getVivoMultiWindowActive()) {
            mMediaRoot.addOnLayoutChangeListener(mMediaRootLayoutChangeListener);
        }
        mMediaRoot.setOnTouchListener(mMediaRootTouchListener);
        mVideoBack.setVisibility(View.VISIBLE);
        mVideoBottomLayout.setClickable(true);
        int visibility = (this.isCellType) || (this.bV.contains(CtrlFlag.hideCloseBtn)) ? View.GONE : View.VISIBLE;
        mVideoClose.setVisibility(visibility);
        this.setVideoMoreIvVisible(View.GONE);
        this.setVideoItemFeedMoreDotVisible(View.GONE);
        mVideoClose.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View view) {
                if (nonNullCallback()) {
                    callback.handleCloseClick(MediaViewLayout.this, view);
                }
            }
        });
        mVideoBack.setVisibility(!this.isCellType || (this.bV.contains(CtrlFlag.alwayShowBackBtn)) ? View.VISIBLE : View.GONE);
        mVideoBack.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View arg3) {
                if (nonNullCallback()) {
                    if (isFullscreenAutoPlayEndCoverVisible()) {
                        callback.handleFullScreenBackClick(MediaViewLayout.this, arg3);
                    } else {
                        callback.handleBackClick(MediaViewLayout.this, arg3);
                    }
                }
            }
        });
        mVideoFullscreenBack.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                if (nonNullCallback()) {
                    callback.handleFullScreenBackClick(MediaViewLayout.this, v);
                }
            }
        });
        mVideoPlay.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                if (MediaViewLayout.this.nonNullCallback()) {
                    MediaViewLayout.this.callback.handlePlayClick(MediaViewLayout.this, v);
                }
            }
        });
        mVideoMoreIv.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                if (MediaViewLayout.this.nonNullCallback()) {
                    MediaViewLayout.this.callback.handleTopMoreClick(MediaViewLayout.this, v);
                }
            }
        });
        mVideoItemFeedMoreDot.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View arg3) {
                if (MediaViewLayout.this.nonNullCallback()) {
                    MediaViewLayout.this.callback.handleFullScreenMoreClick(MediaViewLayout.this, arg3);
                }
            }
        });
        mVideoRetry.setOnClickListener(new View.OnClickListener() {
            public final void onClick(View v) {
                MediaViewLayout.this.setPlayIcon(false, MediaViewLayout.this.isLiveVideo);
                MediaViewLayout.this.dismissRetry();
                MediaViewLayout.this.showLoading();
                if (MediaViewLayout.this.nonNullCallback()) {
                    MediaViewLayout.this.callback.handleRetryClick(MediaViewLayout.this, v);
                }
            }
        });
        mVideoAdGoDetail.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View arg3) {
                if (MediaViewLayout.this.nonNullCallback()) {
                    MediaViewLayout.this.callback.handleAdGoLandingClick(true);
                }
            }
        });
        mVideoFullscreen.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View view) {
                if (nonNullCallback()) {
                    if (!AppData.getInstance().isVideoAccelerated()) {
                        callback.handleFullScreenClick(MediaViewLayout.this, view);
                    } else if (L.mMyOrientationEventListener.getCurrentScreenOrientation() == 8) {
                        callback.handleFullScreenClick(MediaViewLayout.this, view, true, false);
                    } else {
                        callback.handleFullScreenClick(MediaViewLayout.this, view);
                    }
                }
            }
        });
        mVideoAdFullscreen.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View view) {
                if (nonNullCallback()) {
                    if (!AppData.getInstance().isVideoAccelerated()) {
                        callback.handleFullScreenClick(MediaViewLayout.this, view);
                    } else if (L.mMyOrientationEventListener.getCurrentScreenOrientation() == 8) {
                        callback.handleFullScreenClick(MediaViewLayout.this, view, true, false);
                    } else {
                        callback.handleFullScreenClick(MediaViewLayout.this, view);
                    }
                }
            }
        });
        mVideoAdGoDetailBottom.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View view) {
                if (nonNullCallback()) {
                    callback.handleAdGoLandingClick(true);
                }
            }
        });
        mAdSplashJumpBtn.setOnClickListener(new View.OnClickListener() {
            public final void onClick(View view) {
                view.setVisibility(View.INVISIBLE);
                mAdSplashSkipLoading.setVisibility(View.VISIBLE);
                RotateAnimation rotateAnimation = new RotateAnimation(0f, 359f,
                        1, 0.5f, 1, 0.5f);
                rotateAnimation.setDuration(800);
                rotateAnimation.setRepeatCount(10);
                rotateAnimation.setRepeatMode(1);
                rotateAnimation.setInterpolator(new LinearInterpolator());
                mAdSplashSkipLoading.startAnimation(((Animation) rotateAnimation));
                if (nonNullCallback()) {
                    Logger.d("MediaViewLayout", "mSplashAdJumpBtn click callback");
                    callback.handleSplashSkipClick();
                }
            }
        });
        mVideoLiveFullScreen.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                if (nonNullCallback()) {
                    if (!AppData.getInstance().isVideoAccelerated()) {
                        callback.handleFullScreenClick(MediaViewLayout.this, v);
                    } else if (L.mMyOrientationEventListener.getCurrentScreenOrientation() == 8) {
                        callback.handleFullScreenClick(MediaViewLayout.this, v, true, false);
                    } else {
                        callback.handleFullScreenClick(MediaViewLayout.this, v);
                    }
                }
            }
        });
        mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            public final void onProgressChanged(SeekBar seekBar, int arg4, boolean arg5) {
                if (nonNullCallback()) {
                    callback.onProgressChanged(MediaViewLayout.this, seekBar, arg4, arg5);
                }
            }

            public final void onStartTrackingTouch(SeekBar seekBar) {
                if (nonNullCallback()) {
                    callback.onStartTrackingTouch(MediaViewLayout.this, seekBar);
                }
            }

            public final void onStopTrackingTouch(SeekBar seekBar) {
                if (nonNullCallback()) {
                    callback.onStopTrackingTouch(MediaViewLayout.this, seekBar);
                }
            }
        });
        mVideoCoverGoDetail.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                mVideoCoverContainer.setVisibility(View.GONE);
                if (nonNullCallback()) {
                    callback.handleVideoCoverGodetail(MediaViewLayout.this, v);
                }
            }
        });
        mVideoCoverReplay.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                mVideoCoverContainer.setVisibility(View.GONE);
                if (nonNullCallback()) {
                    callback.handleVideoCoverReplay(MediaViewLayout.this, v);
                }
            }
        });
        mMediaThirdParty.setOnClickListener(new View.OnClickListener() {
            public final void onClick(View v) {
                if (nonNullCallback()) {
                    callback.handleThirdPartnerClick();
                }
            }
        });
        mMediaThirdParty.setOnTouchListener(new View.OnTouchListener() {
            public final boolean onTouch(View view, MotionEvent motionEvent) {
                switch (motionEvent.getAction()) {
                    case 0:
                        view.setAlpha(0.6f);
                        break;
                    case 1:
                    case 3:
                        view.setAlpha(1f);
                        break;
                }
                return false;
            }
        });
        if (mMyOnGlobalLayoutListener != null) {
            if (Build.VERSION.SDK_INT >= 16) {
                mVideoAreaRight.getViewTreeObserver().removeOnGlobalLayoutListener(mMyOnGlobalLayoutListener);
            } else {
                mVideoAreaRight.getViewTreeObserver().removeGlobalOnLayoutListener(mMyOnGlobalLayoutListener);
            }
        }

        mMyOnGlobalLayoutListener = new MyOnGlobalLayoutListener(mVideoAreaRight);
        mVideoAreaRight.getViewTreeObserver().addOnGlobalLayoutListener(mMyOnGlobalLayoutListener);
        mVideoActionControlAreaRight.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                try {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("num", q);
                    MobClickCombiner.onEvent(mContext, "video", "clarity_click", getGroupId(), 0, jsonObject);
                    g.serviceMonitor("video_clarity", 0, null);
                } catch (JSONException jsonException) {
                }

                if (mVideoAreaRight.getChildCount() > 0 && mVideoAreaRight.getWidth() > 0) {
                    ViewGroup viewGroup = mVideoAreaRight;
                    float width = (float) mVideoAreaRight.getWidth();
                    MediaViewLayout.startTranslationX(viewGroup, width, mVideoAreaRight.getTranslationX() <= 0f);
                }
            }
        });
        mAdActionLayout.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                Object tag = mAdActionLayout.getTag();
                if (tag != null && tag instanceof Integer && nonNullCallback()) {
                    if ((Integer) tag > 0) {
                        callback.handleTrySkipAdClick();
                    } else {
                        callback.handleAdJumpClick();
                    }
                }
            }
        });
        mVideoFollowCompleteReplay.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                UIUtils.setVisibility(mFinishInfoLayout, 8);
                if (mArticle != null) {
                    String categoryLabel = callback.getCategoryLabel("click");
                    JSONObject jsonObject = new JSONObject();
                    try {
                        if (isCellType) {
                            jsonObject.put("position", "list_video_over");
                        } else {
                            jsonObject.put("position", "detail_video_over");
                        }
                    } catch (Exception e) {
                    }
                    MobClickCombiner.onEvent(mContext, "replay", categoryLabel, mArticle.groupId, 0, jsonObject);
                }

                if (nonNullCallback()) {
                    callback.handleReplayClick();
                }
            }
        });
        mLLReplay.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                UIUtils.setVisibility(mRLVideoEndCover, 8);
                if (nonNullCallback()) {
                    callback.handleReplayClick();
                }
            }
        });
        mIvShareWechat.setOnClickListener(new View.OnClickListener() {
            public final void onClick(View view) {
                if (MediaViewLayout.this.nonNullCallback()) {
                    MediaViewLayout.this.callback.handleItemShareClick(2);
                }
            }
        });
        mIvShareMoment.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                if (nonNullCallback()) {
                    callback.handleItemShareClick(1);
                }
            }
        });
        mIvShareQQ.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                if (nonNullCallback()) {
                    callback.handleItemShareClick(3);
                }
            }
        });
        mIvShareQzone.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                if (nonNullCallback()) {
                    callback.handleItemShareClick(3);
                }
            }
        });
        mVideoFollowCompleteShare.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                if (mArticle != null) {
                    String v3 = callback.getCategoryLabel("click");
                    JSONObject v8 = new JSONObject();
                    try {
                        if (isCellType) {
                            v8.put("position", "list_video_over");
                        } else {
                            v8.put("position", "detail_video_over");
                        }
                    } catch (Exception v0) {
                    }
                    MobClickCombiner.onEvent(mContext, "share", v3, mArticle.groupId, 0, v8);
                }

                if (nonNullCallback()) {
                    callback.handleShareClick();
                }
            }
        });
        mAutoPlayEndCoverVideoEndCoverImageIv.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View view) {
                boolean isAutoPlay = !android.support.design.a.isTextEquals(mTvAutoPlay.getText().toString(),
                        mContext.getString(com.ss.android.article.browser.R.string.next_video));
                dismissAllEndCover();
                if ((nonNullCallback()) && !isCellType) {
                    VideoAutoPlayHelperDetail videoAutoPlayHelperDetail = callback.getVideoAutoPlayHelperDetail();
                    if (videoAutoPlayHelperDetail != null) {
                        videoAutoPlayHelperDetail.reportNextPlay(mContext, isFullscreen, false, isAutoPlay);
                        videoAutoPlayHelperDetail.a(callback);
                    }
                }
            }
        });
        mFullscreenAutoPlayEndCoverVideoEndCoverImageIv.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                boolean isAutoPlay = !android.support.design.a.isTextEquals(mFullscreenAutoPlayEndCoverTvAutoPlay.getText().toString(),
                        mContext.getString(com.ss.android.article.browser.R.string.next_video));
                dismissAllEndCover();
                if ((nonNullCallback()) && !isCellType) {
                    VideoAutoPlayHelperDetail videoAutoPlayHelperDetail = callback.getVideoAutoPlayHelperDetail();
                    if (videoAutoPlayHelperDetail != null) {
                        videoAutoPlayHelperDetail.reportNextPlay(mContext, isFullscreen, false, isAutoPlay);
                        videoAutoPlayHelperDetail.a(callback);
                    }
                }
            }
        });
        mTvCancelAutoPlay.setOnTouchListener(new View.OnTouchListener() {

            public final boolean onTouch(View view, MotionEvent motionEvent) {
                if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                    boolean isAutoPlay = !android.support.design.a.isTextEquals(mTvAutoPlay.getText().toString(),
                            mContext.getString(com.ss.android.article.browser.R.string.next_video));
                    if (!isCellType) {
                        VideoAutoPlayHelperDetail videoAutoPlayHelperDetail = callback.getVideoAutoPlayHelperDetail();
                        if (videoAutoPlayHelperDetail != null) {
                            videoAutoPlayHelperDetail.reportCancelPlay(mContext, isFullscreen, isAutoPlay);
                        }
                        if (isCellType) {
                            dismissAllEndCover();
                            return true;
                        }

                        if (!isAutoPlayEndCoverVisible() && !isFullscreenAutoPlayEndCoverVisible()) {
                            dismissAllEndCover();
                            return true;
                        }

                        if (nonNullCallback()) {
                            videoAutoPlayHelperDetail = callback.getVideoAutoPlayHelperDetail();
                            if (videoAutoPlayHelperDetail != null) {
                                videoAutoPlayHelperDetail.b(mContext);
                            }
                        }
                        dismissAllEndCover();
                        showNewCover(mArticle);
                    }
                    dismissAllEndCover();
                }

                return true;
            }
        });
        mFullscreenAutoPlayEndCoverTvCancelAutoPlay.setOnClickListener(new View.OnClickListener() {

            public final void onClick(View v) {
                boolean v0 = !android.support.design.a.isTextEquals(
                        mFullscreenAutoPlayEndCoverTvAutoPlay.getText().toString(),
                        mContext.getString(com.ss.android.article.browser.R.string.next_video));
                if (!isCellType) {
                    VideoAutoPlayHelperDetail v1 = callback.getVideoAutoPlayHelperDetail();
                    if (v1 != null) {
                        v1.reportCancelPlay(mContext, isFullscreen, v0);
                    }

                    callback.handleFullScreenBackClick(MediaViewLayout.this, v);
                    showNewCover(mArticle);
                }

                dismissAllEndCover();
            }
        });
    }

    public final int getClarityCount() {
        return this.q;
    }

    public final int getContainerHeight() {
        return mContainerHeight;
    }

    public final FrameLayout.LayoutParams getLayoutParams() {
        FrameLayout.LayoutParams v0_1;
        if ((mMediaRoot.getLayoutParams() instanceof FrameLayout.LayoutParams)) {
            v0_1 = (FrameLayout.LayoutParams) mMediaRoot.getLayoutParams();
        } else {
            v0_1 = null;
        }

        return v0_1;
    }

    public final void setLayoutParams(FrameLayout.LayoutParams arg2) {
        mMediaRoot.setLayoutParams(((ViewGroup.LayoutParams) arg2));
    }

    public final VideoItem getSelectClarity() {
        Object v0_1;
        VideoItem v1 = null;
        int v0;
        for (v0 = 0; v0 < mVideoAreaRight.getChildCount(); ++v0) {
            View v2 = mVideoAreaRight.getChildAt(v0);
            if ((v2.isSelected()) && ((v2.getTag() instanceof VideoItem))) {
                v0_1 = v2.getTag();
                return ((VideoItem) v0_1);
            }
        }
        v0_1 = v1;
        return (VideoItem) v0_1;
    }

    public final int getVisibility() {
        return this.bN;
    }

    public final void setVisibility(int arg3) {
        this.bN = arg3;
        if (!this.bV.contains(CtrlFlag.alwayShowMediaView)) {
            UIUtils.setVisibility(mMediaRoot, arg3);
        }
    }

    public final void handleBtnAdShowOrHide(Boolean arg3) {
        if (mLargeButtonAd != null) {
            if ((arg3.booleanValue()) && (this.bR)) {
                mLargeButtonAd.a(Boolean.valueOf(true));
                return;
            }

            mLargeButtonAd.a(Boolean.valueOf(false));
        }
    }

    public final void handleMsg(Message message) {
        View v4 = null;
        switch (message.what) {
            case MSG_DISMISS_TOOLBAR:
                this.dismissToolBar();
                break;
            case 2: //
                int v0 = message.arg1;
                if (!this.isAutoRotateEnabled) {
                    return;
                }

                if (v0 == this.getScreenRotation()) {
                    return;
                }

                if (v0 == -1) {
                    return;
                }

                if (v0 == 1) {
                    if ((this.isFullScreen()) && (this.nonNullCallback())) {
                        this.callback.handleFullScreenBackClick(((IMediaLayout) this), v4, true);
                    }

                    mSurfaceChangedTime = SystemClock.uptimeMillis();
                    return;
                }

                if (this.nonNullCallback()) {
                    if (this.isFullScreen()) {
                        this.callback.requestOrienation(v0);
                    } else {
                        IMediaCallback v2 = this.callback;
                        boolean v0_1 = v0 == 8 ? true : false;
                        v2.handleFullScreenClick(((IMediaLayout) this), v4, v0_1, true);
                    }
                }

                mSurfaceChangedTime = SystemClock.uptimeMillis();
                break;
        }
    }

    private void setVideoActionControlAreaRightColor() {
        int colorResId = mVideoAreaRight.getChildCount() > 0
                ? com.ss.android.article.browser.R.color.ssxinzi12
                : com.ss.android.article.browser.R.color.ssxinzi11;
        mVideoActionControlAreaRight.setTextColor(mContext.getResources().getColor(colorResId));
    }

    public final boolean isAutoRotateEnabled() {
        return this.isAutoRotateEnabled;
    }

    public final boolean isCellType() {
        return this.isCellType;
    }

    public final boolean isEndCoverLayoutVisible() {
        return mAutoPlayEndCover != null && mAutoPlayEndCover.getVisibility() == View.VISIBLE;
    }

    public final boolean isFullScreen() {
        return this.isFullscreen;
    }

    public final boolean isNoWifiDialogShowing() {
        return mDialog != null && mDialog.isShowing();
    }

    public final boolean isSurfaceViewValid() {
        return this.isSurfaceCreated;
    }

    private int getScreenRotation() {
        int v0;
        if (mWindowManager != null) {
            switch (mWindowManager.getDefaultDisplay().getRotation()) {
                case 0: {
                    return 1;
                }
                case 1: {
                    return 0;
                }
                case 2: {
                    return 9;
                }
                case 3: {
                    return 8;
                }
            }
            return -1;
        } else {
            v0 = -1;
        }
        return v0;
    }

    public final void onAccountRefresh(boolean arg1) {
    }

    public final boolean outOfBuffer(int arg2) {
        boolean v0 = mSeekBar == null || arg2 <= mSeekBar.getSecondaryProgress() ? false : true;
        return v0;
    }

    public final void releaseMediaPlayer() {
        this.setKeepScreenOn(false);
        this.disableAutoRotate();
        mSeekBar.setProgress(0);
        mSeekBar.setSecondaryProgress(0);
        mVideoProgress.setProgress(0);
        mVideoProgress.setSecondaryProgress(0);
        this.setVisibility(View.GONE);
        if (!this.bV.contains(CtrlFlag.alwayShowMediaView)) {
            mVideoSurface.setVisibility(View.GONE);
        }

        mVideoCoverContainer.setVisibility(View.GONE);
        if (AppData.getInstance().getAbSettings().isVideoPlayerShare()) {
            mRLVideoEndCover.setVisibility(View.GONE);
        } else {
            mFinishInfoLayout.setVisibility(View.GONE);
        }

        mVideoAdGoDetail.setVisibility(View.GONE);
        mAdSplashJumpBtn.setVisibility(View.INVISIBLE);
        mAdSplashIgnore.setVisibility(View.GONE);
        mAdSplashHasWifiLoaded.setVisibility(View.GONE);
        mAdSplashLogo.setVisibility(View.GONE);
        mAdSplashSkipLoading.setVisibility(View.INVISIBLE);
        mVideoLiveCoverContainer.setVisibility(View.GONE);
        mImageLoader.onStop();
        mVideoTimeLeftTime.setText("00:00");
        mVideoTimePlay.setText("00:00");
        if (mVideoCoverImage != null) {
            mVideoCoverImage.setImageDrawable(null);
        }

        if (mVideoLoadingCoverImage != null) {
            mVideoLoadingCoverImage.setImageDrawable(null);
        }

        if (mMediaRoot != mMediaPlayLayout) {
            mMediaRoot = mMediaPlayLayout;
            this.initView(mMediaRoot);
            this.bindListener();
        }

        this.setVisibility(View.GONE);
        mAdActionLayout.setVisibility(View.GONE);
        mVideoAdBottomLayout.setVisibility(View.GONE);
        this.I = false;
        this.isDirectPlay = false;
        this.J = false;
        this.isLiveVideo = false;
        this.bS = true;
    }

    public final void removeDismissToolBarMsg() {
        mWeakHandler.removeMessages(1);
    }

    public final void removeMediaView() {
        if (mMediaPlayLayout != null && mMediaPlayLayout.getParent() != null) {
            ((ViewGroup) mMediaPlayLayout.getParent()).removeView(mMediaPlayLayout);
        }
    }

    public final void resetClaritySelectors() {
        mVideoAreaRight.removeAllViews();
        this.q = 0;
        this.setVideoActionControlAreaRightColor();
    }

    public final void reshowEndCover() {
        int v1 = 1;
        int v0 = 0;
        if (mAutoPlayEndCover != null && mAutoPlayEndCover.getVisibility() == View.VISIBLE) {
            v0 = 1;
        }

        if (!this.isFullscreenAutoPlayEndCoverVisible()) {
            v1 = v0;
        }

        if (v1 != 0 && mAutoPlayDelaySeconds <= 0 && !this.isCellType) {
            mAutoPlayDelaySeconds = 5;
            if (this.isFullScreen()) {
                this.showFullscreenAutoPlayEndCover(mNextVideoArticle);
            } else {
                this.showAutoPlayEndCover(mNextVideoArticle);
            }

            mWeakHandler.postDelayed(mEndCoverCountdownRunnable, 1000);
        }
    }

    public final void restoreClaritySelectByCache(String arg8, SparseArray arg9) {
        if (!TextUtils.isEmpty(((CharSequence) arg8))) {
            if (mVideoAreaRight.getChildCount() > 0) {
                mVideoAreaRight.removeAllViews();
            }

            this.q = 0;
            int v2;
            for (v2 = 0; v2 < arg9.size(); ++v2) {
                Object v0 = arg9.get(v2);
                if (v0 != null) {
                    ViewGroup v4 = mVideoAreaRight;
                    View v1 = LayoutInflater.from(mContext).inflate(com.ss.android.article.browser.R.layout.jg, v4, false);
                    if (v4.getChildCount() <= 0) {
                        UIUtils.setLayoutMargins(v1, 0, 0, 0, 0);
                    }

                    ((TextView) v1).setSelected(false);
                    if (TextUtils.equals(((VideoItem) v0).definition, "720p")) {
                        ((TextView) v1).setText("超清");
                    } else if (TextUtils.equals(((VideoItem) v0).definition, "480p")) {
                        ((TextView) v1).setText("高清");
                    } else if (TextUtils.equals(((VideoItem) v0).definition, "360p")) {
                        ((TextView) v1).setText("标清");
                    } else {
                        ((TextView) v1).setText(((VideoItem) v0).definition);
                    }

                    ((TextView) v1).setTag(v0);
                    ((TextView) v1).setOnClickListener(new View.OnClickListener() {

                        public final void onClick(View v) {
                            if ((v.getTag() instanceof VideoItem)) {
                                Object v0 = v.getTag();
                                if (v0 != null) {
                                    setSelectClarityItem(((VideoItem) v0), v);
                                    VideoClarityHelper.setDefaultVideoClarity(VideoClarityHelper.getClarity(((VideoItem) v0).definition));
                                }
                            }
                        }
                    });
                    v4.addView(v1);
                    v1.setSelected(TextUtils.equals(((CharSequence) arg8), ((VideoItem) v0).definition));
                    ++this.q;
                }
            }

            this.setVideoActionControlAreaRightColor();
        }
    }

    @Override
    public final void sendDismissToolBarMsg() {
        mWeakHandler.removeMessages(MSG_DISMISS_TOOLBAR);
        mWeakHandler.sendMessageDelayed(mWeakHandler.obtainMessage(MSG_DISMISS_TOOLBAR), 2000L);
    }

    public final void setAdGoLanding(boolean visible) {
        int visibility = visible ? View.VISIBLE : View.GONE;
        mVideoAdGoDetail.setVisibility(visibility);
    }

    public final void setBtnAdInfo(BaseAdsData arg4, WeakReference arg5) {
        if (mLargeButtonAd != null) {
            mLargeButtonAd.setContextRef(arg5);
            if (!(arg4 instanceof FeedDownloadAppAd)) {
                mLargeButtonAd.d();
                this.bR = false;
            } else if (((FeedDownloadAppAd) arg4).uiType == 1) {
                mLargeButtonAd.d();
                this.bR = false;
                this.bS = false;
            } else {
                this.bR = mLargeButtonAd.a(arg4);
            }
        }
    }

    public final void setCallback(IMediaCallback callback) {
        this.callback = callback;
    }

    public final void setContainerLayoutParams(int width, int height) {
        ViewGroup.LayoutParams layoutParams = mMediaRoot.getLayoutParams();
        if (width == MATCH_PARENT || width == WRAP_CONTENT || width > 0) {
            layoutParams.width = width;
        }

        if (height == MATCH_PARENT || height == WRAP_CONTENT || height > 0) {
            layoutParams.height = height;
        }
        mMediaRoot.setLayoutParams(layoutParams);
    }

    public final void setContainerSize(int width, int height) {
        int containerHeight;
        if (width == MATCH_PARENT) {
            width = mContext.getResources().getDisplayMetrics().widthPixels;
        }

        if (width > 0) {
            mContainerWidth = width;
            if ((this.isCellType()) || (this.isFullScreen()) || (this.bV.contains(CtrlFlag.fixedSize))) {
                containerHeight = height;
            } else {
                if (mVideoWidth > 0 && mVideoHeight > 0) {
                    int maxVideoContainerHeight = mContext.getResources().getDimensionPixelSize(com.ss.android.article.browser.R.dimen.max_video_container_height);
                    int minVideoContainerHeight = mContext.getResources().getDimensionPixelSize(com.ss.android.article.browser.R.dimen.min_video_container_height);
                    int calculateHeight = (int) ((float) width / (float) mVideoWidth * (float) mVideoHeight);
                    if (calculateHeight <= maxVideoContainerHeight) {
                        containerHeight = calculateHeight < minVideoContainerHeight ? minVideoContainerHeight : calculateHeight;
                    } else {
                        containerHeight = maxVideoContainerHeight;
                    }
                } else {
                    containerHeight = 0;
                }
            }
            mContainerHeight = containerHeight;
            this.setContainerLayoutParams(mContainerWidth, mContainerHeight);
        }
    }

    public final void setDetailAutoPlayKeepFullScreen(boolean detailAutoPlayKeepFullScreen) {
        this.isDetailAutoPlayKeepFullScreen = detailAutoPlayKeepFullScreen;
    }

    public final void setDirectPlay(boolean directPlay) {
        this.isDirectPlay = directPlay;
    }

    public final void setIsLiveVideo(boolean isLiveVideo) {
        this.isLiveVideo = isLiveVideo;
        mVideoLiveTip.setDrawable(ContextCompat.getDrawable(mContext, com.ss.android.article.browser.R.drawable.live_video_tip), true);
        mVideoLiveTip.setText(mContext.getString(com.ss.android.article.browser.R.string.live_video_tip), true);
    }

    public final void setIsPatchVideo(boolean arg5, boolean isAd) {
        this.I = arg5;
        if (arg5) {
            mVideoBottomLayout.setVisibility(View.GONE);
            mAdJumpBtn.setVisibility(isAd ? View.GONE : View.VISIBLE);
            mAdLeftJumpLine.setVisibility(!isAd ? View.VISIBLE : View.GONE);
        } else {
            mAdActionLayout.setVisibility(View.GONE);
            mVideoAdBottomLayout.setVisibility(View.GONE);
        }
    }

    public final void setIsSplashAdVideo(boolean arg4, boolean showSplashLogo, boolean showJumpBtn) {
        this.J = arg4;
        if (this.J) {
            mVideoBottomLayout.setVisibility(View.GONE);
            mVideoTopLayout.setVisibility(View.GONE);
            mVideoLoadingProgress.setVisibility(View.GONE);
            if (showSplashLogo) {
                mAdSplashLogo.setVisibility(View.VISIBLE);
                mAdSplashHasWifiLoaded.setVisibility(View.VISIBLE);
            }

            if (showJumpBtn) {
                mAdSplashIgnore.setVisibility(View.VISIBLE);
                mAdSplashJumpBtn.setVisibility(View.VISIBLE);
            }
        }
    }

    public final void setKeepScreenOn(boolean keepScreenOn) {
        if (mVideoSurface != null) {
            View view = mVideoSurface.getView();
            if ((view instanceof TextureView)) {
                view.setKeepScreenOn(keepScreenOn);
            }
        }
    }

    public final void setOuterVideoCellType(int outerVideoCellType) {
        this.mOuterVideoCellType = outerVideoCellType;
    }

    public final void setPlayIcon(boolean arg3, boolean isLive) {
        if (this.isDirectPlay || this.J) {
            mVideoCoverContainer.setVisibility(View.GONE);
            mVideoPlay.setVisibility(View.GONE);
        }

        if (this.I && AppData.getInstance().isPosterAdClickEnabled()) {
            mVideoCoverContainer.setVisibility(View.GONE);
            mVideoPlay.setVisibility(View.GONE);
        }

        this.bJ = arg3;
        if (mVideoPlay != null) {
            if (!arg3) {
                if (isLive || !isFullscreen) {
                    mVideoPlay.setImageResource(com.ss.android.article.browser.R.drawable.media_pause_icon_selector);
                } else {
                    mVideoPlay.setImageResource(com.ss.android.article.browser.R.drawable.media_pause_icon);
                }
            } else if (isLive) {
                mVideoPlay.setImageResource(com.ss.android.article.browser.R.drawable.media_pause_icon_live_selector);
            } else if (isFullscreen) {
                mVideoPlay.setImageResource(com.ss.android.article.browser.R.drawable.media_play_icon);
            } else {
                mVideoPlay.setImageResource(com.ss.android.article.browser.R.drawable.play_movebar_textpage);
            }
        }
    }

    public final void setPlayerSurfaceViewSize(boolean arg12) {
        double v4 = 0;
        int v0 = this.isFullScreen() ? mLastHeight : mContainerWidth;
        int v1 = this.isFullScreen() ? mLastWidth : mContainerHeight;
        if (mVideoHeight > 0 && mVideoWidth > 0 && v0 > 0) {
            if (!this.isCellType() && !this.isFullScreen() && !this.bV.contains(CtrlFlag.fixedSize)) {
                v1 = mContext.getResources().getDimensionPixelSize(com.ss.android.article.browser.R.dimen.max_video_container_height);
            }

            int v2 = ((int) ((((float) v0)) / (((float) mVideoWidth)) * (((float) mVideoHeight))));
            if (v2 > v1) {
                v0 = v1;
                v1 = ((int) ((((float) v1)) / (((float) mVideoHeight)) * (((float) mVideoWidth))));
            } else {
                v1 = v0;
                v0 = v2;
            }

            if (!arg12 && !this.isFullScreen()) {
                v1 = mContainerWidth;
                v0 = mContainerHeight;
            }

            if ((AppData.getInstance().getAbSettings().isPersistVivoMultiWindow()) && (getVivoMultiWindowActive())) {
                if (this.isFullScreen()) {
                    double v2_1 = mVideoWidth != 0 ? (double) mVideoHeight / (double) mVideoWidth : v4;
                    double v6 = mLastWidth != 0 ? (double) mLastHeight / (double) mLastWidth : v4;
                    if (v6 >= v2_1) {
                        v1 = mLastWidth;
                        v0 = ((int) (v2_1 * (((double) mLastWidth))));
                    } else {
                        if (v2_1 > v4) {
                            v1 = ((int) ((((double) mLastHeight)) / v2_1));
                        }
                        v0 = mLastHeight;
                    }
                } else {
                    v1 = mLastWidth;
                }
            }
            mVideoSurface.resize(v1, v0);
        }
    }

    public final void setSeekProgress(int progress) {
        if (this.isDirectPlay || this.I || this.J) {
            mVideoProgress.setVisibility(View.GONE);
        } else {
            if (mVideoBottomLayout != null && mVideoBottomLayout.getVisibility() == View.VISIBLE) {
                mVideoProgress.setVisibility(View.GONE);
                return;
            }

            mVideoProgress.setVisibility(View.VISIBLE);
            mSeekBar.setProgress(progress);
            mVideoProgress.setProgress(progress);
        }
    }

    public final void setSeekSecondaryProgress(int progress) {
        if (this.isDirectPlay || this.I || this.J) {
            mVideoProgress.setVisibility(View.GONE);
        } else if (mVideoBottomLayout != null && mVideoBottomLayout.getVisibility() == View.VISIBLE) {
            mVideoProgress.setVisibility(View.GONE);
        } else {
            mVideoProgress.setVisibility(View.VISIBLE);
            mSeekBar.setSecondaryProgress(progress);
            mVideoProgress.setSecondaryProgress(progress);
        }
    }

    public final void setSelectClarityItem(VideoItem videoItem, View arg12) {
        if (videoItem != null) {
            if (arg12 != null) {
                try {
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("num", this.q);
                    jsonObject.put("definition", videoItem.definition);
                    MobClickCombiner.onEvent(mContext, "video", "clarity_select", this.getGroupId(), 0, jsonObject);
                    com.bytedance.article.common.a.g.serviceMonitor("video_clarity", 1, null);
                } catch (JSONException v0) {
                }
            }

            VideoItem v2 = this.getSelectClarity();
            int v1;
            for (v1 = 0; v1 < mVideoAreaRight.getChildCount(); ++v1) {
                View v3 = mVideoAreaRight.getChildAt(v1);
                if ((v3.getTag() instanceof VideoItem)) {
                    v3.setSelected(TextUtils.equals(((VideoItem) v3.getTag()).definition, videoItem.definition));
                }
            }

            if (v2 != null && arg12 != null && !TextUtils.equals(v2.definition, videoItem.definition)) {
                this.callback.handleClarityChange();
            }

            this.setVideoActionControlAreaRightColor();
            if (arg12 == null) {
                return;
            }

            this.translatioXVideoAreaRight(true);
        }
    }

    public final void setSurfaceViewVisible(int arg3) {
        mMediaRoot.setVisibility(View.VISIBLE);
        if (mVideoSurface != null) {
            mVideoSurface.setVisibility(arg3);
        }
    }

    public final void setTheme(boolean arg5) {
        int v2 = com.ss.android.article.browser.R.color.video_player_text;
        if (this.v != arg5) {
            this.v = arg5;
            mVideoTitle.setTextColor(mContext.getResources().getColor(v2));
            mVideoTimePlay.setTextColor(mContext.getResources().getColor(v2));
            mVideoTimeLeftTime.setTextColor(mContext.getResources().getColor(v2));
            this.setPlayIcon(true, false);
            mVideoFullscreen.setImageResource(com.ss.android.article.browser.R.drawable.enlarge_video);
            mVideoRetry.setImageResource(com.ss.android.article.browser.R.drawable.refreshing_video_textpage);
            mVideoRetryDes.setTextColor(mContext.getResources().getColor(com.ss.android.article.browser.R.color.xc));
            mVideoBack.setCompoundDrawablesWithIntrinsicBounds(com.ss.android.article.browser.R.drawable.shadow_btn_back, 0, 0, 0);
            mVideoFullscreenBack.setImageResource(com.ss.android.article.browser.R.drawable.leftbackbutton_titlebar_photo_preview);
            mVideoClose.setImageResource(com.ss.android.article.browser.R.drawable.close_move_detail);
            mLargeButtonAd.b(arg5);
        }
    }

    public final void setThirdImageUrl(String thirdImageUrl) {
        if (!android.support.design.a.isTextEmpty(thirdImageUrl)) {
            this.mThirdImageUrl = thirdImageUrl;
            if (mMediaThirdParty != null) {
                mMediaThirdParty.setUrl(this.mThirdImageUrl);
            }
        }
    }

    public final void setTimeDesc(long totalPlayLength, long duration) {
        if (!this.I && !this.J) {
            mVideoTimeLeftTime.setText(convert2readableString(duration));
            mVideoTimePlay.setText(convert2readableString(totalPlayLength));
            int progress = 0;
            if (duration > 0) {
                progress = (int) ((double) totalPlayLength / (double) duration * 100);
            }
            mSeekBar.setProgress(progress);
        }
    }

    public final void setTitle(String title) {
        if ((this.I) || (this.J)) {
            mVideoTitle.setVisibility(View.GONE);
            mVideoFullscreenTitle.setVisibility(View.GONE);
        } else {
            if (mVideoTitle != null) {
                mVideoTitle.setText(title);
            }
            if (mVideoFullscreenTitle != null) {
                mVideoFullscreenTitle.setText(title);
            }
        }
    }

    public final void setTitleTextSize(int textSize) {
        if (mVideoTitle != null) {
            mVideoTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, ((float) textSize));
        }
    }

    public final void setVideoSize(int videoWidth, int videoHeight) {
        mVideoWidth = videoWidth;
        mVideoHeight = videoHeight;
    }

    public final void showCover(ImageInfo imageInfo, boolean arg6) {
        mVideoCoverContainer.setVisibility(View.VISIBLE);
        Log.d("travis", "MediaViewLayout::::showCover()   imageInfo=" + imageInfo.toJsonObj());
        mImageLoader.loadImage(mVideoCoverImage, imageInfo, false);
        int visibility = arg6 && !this.isFullscreen ? View.VISIBLE : View.GONE;
        mVideoCoverGoDetail.setVisibility(visibility);

        UIUtils.setVisibility(mVideoCoverBack, arg6 ? View.GONE : View.VISIBLE);
    }

    public final void showEndCover(CellRef cellRef, Article article) {
        if (this.nonNullCallback()) {
            this.dismissNewCover();
            this.callback.unregisterStopEndCoverCallback();
            this.callback.unregisterReshowEndCoverCallback();
            mAutoPlayDelaySeconds = 5;
            if (!this.isCellType) {
                mNextVideoArticle = article;
                VideoAutoPlayHelperDetail videoAutoPlayHelperDetail = this.callback.getVideoAutoPlayHelperDetail();
                if (videoAutoPlayHelperDetail != null) {
                    ArticleShareHelper articleShareHelper = null;
                    if (videoAutoPlayHelperDetail.mArticleShareHelperRef != null) {
                        articleShareHelper = videoAutoPlayHelperDetail.mArticleShareHelperRef.get();
                    }

                    int v0_1;
                    if (articleShareHelper != null && articleShareHelper.y) {
                        v0_1 = 1;
                    } else if (DialogShowHelper.getInst().isDlgShow()) {
                        v0_1 = 1;
                    } else {
                        v0_1 = 0;
                    }

                    if (v0_1 == 0) {
                    } else if (this.isFullScreen()) {
                    } else {
                        mAutoPlayDelaySeconds = 0;
                        this.callback.registerStopEndCoverCallback();
                        this.callback.registerReshowEndCoverCallback();
                        this.showAutoPlayEndCover(mNextVideoArticle);
                        videoAutoPlayHelperDetail.a(mContext, this.isFullscreen, false);
                        return;
                    }
                }
            }

            this.callback.registerStopEndCoverCallback();
            this.callback.registerReshowEndCoverCallback();
            if (this.isFullScreen()) {
                this.showFullscreenAutoPlayEndCover(mNextVideoArticle);
            } else {
                this.showAutoPlayEndCover(mNextVideoArticle);
            }

            if (!this.isCellType) {
                VideoAutoPlayHelperDetail videoAutoPlayHelperDetail = this.callback.getVideoAutoPlayHelperDetail();
                if (videoAutoPlayHelperDetail != null) {
                    videoAutoPlayHelperDetail.a(mContext, this.isFullscreen, true);
                }
            }
            if ((this.isCellType) && !this.isFullScreen()) {
                return;
            }
            mWeakHandler.postDelayed(mEndCoverCountdownRunnable, 1000);
        }
    }

    public final void showEndCoverOnResume(Article article) {
        mAutoPlayDelaySeconds = 0;
        if (!this.isCellType && !this.isFullScreen()) {
            this.showAutoPlayEndCover(article);
        }
    }

    public final void showHideBottomLayout(boolean arg1) {
    }

    public final void showLiveError(String liveVideoStatus, boolean liveCoverBackVisible) {
        mVideoLiveCoverContainer.setVisibility(View.VISIBLE);
        mLiveVideoStatus.setText(liveVideoStatus);
        UIUtils.setVisibility(mVideoLiveCoverBack, liveCoverBackVisible ? View.VISIBLE : View.GONE);
    }

    public final void showLoading() {
        mVideoLoadingRetryLayout.setVisibility(View.VISIBLE);
        mVideoLoadingProgress.setVisibility(View.VISIBLE);
        mVideoLoadingRetry.setVisibility(View.GONE);
        this.setVideoMoreIvVisible(View.GONE);
        if (mVideoPlay.getVisibility() == View.VISIBLE) {
            mVideoPlay.setVisibility(View.GONE);
        }
        if (mVideoBottomLayout.getVisibility() == View.VISIBLE) {
            mVideoBottomLayout.setVisibility(View.GONE);
        }
    }

    @Override
    public final void showLoadingCover(ImageInfo imageInfo) {
        mVideoLoadingCover.setVisibility(View.VISIBLE);
        android.support.design.a.setImage(mVideoLoadingCoverImage, imageInfo);
    }

    @Override
    public final void showMediaPlayer(ViewGroup container) {
        if (mMediaRoot.getParent() != null) {
            ((ViewGroup) mMediaRoot.getParent()).removeView(mMediaRoot);
        }
        container.addView(mMediaRoot);
        this.setVisibility(View.VISIBLE);
        mVideoCoverContainer.setVisibility(View.GONE);
        mImageLoader.onPause();
    }

    public final void showNewCover(Article article) {
        Log.d("travis", "MediaViewLayout::showNewCover()#1");
        if (!this.bR) {
            mArticle = article;
            if ((this.nonNullCallback()) && article != null) {
                String categoryLabel = this.callback.getCategoryLabel("show");
                JSONObject jsonObject = new JSONObject();
                try {
                    if (this.isCellType) {
                        jsonObject.put("position", "list_video_over");
                    } else {
                        jsonObject.put("position", "detail_video_over");
                    }
                } catch (Exception exception) {
                }
                MobClickCombiner.onEvent(mContext, "replay", categoryLabel, article.groupId, 0L, jsonObject);
                MobClickCombiner.onEvent(mContext, "share", categoryLabel, article.groupId, 0L, jsonObject);
            }

            UIUtils.setVisibility(mVideoCoverContainer, View.GONE);
            this.dismissToolBar(false, true);
            if (article != null) {
                if (article.largeImageList != null) {
                    android.support.design.a.setImage(mVideoFinishCoverImage, article.largeImageList);
                } else if (article.mLoadingCoverImageInfo != null) {
                    android.support.design.a.setImage(mVideoFinishCoverImage, article.mLoadingCoverImageInfo);
                } else if (article.middleImage != null) {
                    android.support.design.a.setImage(mVideoFinishCoverImage, article.middleImage);
                }

                UIUtils.setText(mCoverTitle, article.title);
                mVideoTime.setText(ArticleHelper.convert2ReadableString(article.videoDuration), false);
            }

            if (!this.isCellType) {
                UIUtils.setVisibility(mCoverTitle, View.GONE);
                UIUtils.setVisibility(mVideoTime, View.GONE);
                UIUtils.setVisibility(mVideoBack, 0);
            }

            UIUtils.setVisibility(mVideoPlay, View.GONE);
            this.setVideoMoreIvVisible(View.GONE);
            if (AppData.getInstance().getAbSettings().isVideoPlayerShare()) {
                UIUtils.setVisibility(mRLVideoEndCover, 0);
            } else {
                UIUtils.setVisibility(mFinishInfoLayout, 0);
            }
        }
    }

    @Override
    public final boolean showNoWifiNoticeDialog(Context context) {
        if (context != null) {
            AppData.getInstance();
            AlertDialog.Builder builder = com.ss.android.j.b.createDialogBuilder(context);
            builder.setMessage(com.ss.android.article.browser.R.string.video_mobile_play_dlg_content);
            builder.setPositiveButton(com.ss.android.article.browser.R.string.video_mobile_play, new DialogInterface.OnClickListener() {

                public final void onClick(DialogInterface dialog, int which) {
                    AppData.getInstance().userAllowUseMobileNet = true;
                    if (nonNullCallback()) {
                        callback.handleNoWifiPositiveClick();
                    }
                }
            });
            builder.setNegativeButton(com.ss.android.article.browser.R.string.video_mobile_stop, new DialogInterface.OnClickListener() {

                public final void onClick(DialogInterface dialog, int which) {
                    if (nonNullCallback()) {
                        callback.handleNoWifiCancelClick();
                    }
                }
            });
            builder.setCancelable(false);
            try {
                mDialog = builder.create();
                if (mDialog == null) {
                    return false;
                }

                if (mDialog.isShowing()) {
                    return false;
                }

                mDialog.show();
                return true;
            } catch (Exception exception) {
            }
        }
        return false;
    }

    public final void showOrHideWatermark(boolean arg3) {
        int v1 = 8;
        if (!AppData.getInstance().getAbSettings().isShowWaterMark()) {
            UIUtils.setVisibility(mIvWatermark, v1);
        } else if (arg3) {
            UIUtils.setVisibility(mIvWatermark, 0);
        } else {
            UIUtils.setVisibility(mIvWatermark, v1);
        }
    }

    public final void showPatchRelativeView(boolean arg5) {
        int v2 = View.GONE;
        int v1 = View.VISIBLE;
        View v3 = mVideoAdBottomLayout;
        int v0 = arg5 ? View.VISIBLE : v2;
        v3.setVisibility(v0);
        View v0_1 = mAdActionLayout;
        if (!arg5) {
            v1 = v2;
        }

        v0_1.setVisibility(v1);
    }

    public final void showPlayBtn(boolean visible) {
        int visibility = visible ? View.VISIBLE : View.GONE;
        mVideoPlay.setVisibility(visibility);
    }

    public final void showRelatedVideo(Object obj, View view) {
        Log.d("travis", "MediaViewLayout:::showRelatedVideo()#1    this.I=" + this.I + "   this.J=" + this.J + "   this.bR=" + this.bR);
        if (obj instanceof Article && !this.I && !this.J && !this.bR) {
            mVideoCoverContainer.setVisibility(View.VISIBLE);
            mImageLoader.loadImage(mVideoCoverImage, ((Article) obj).largeImageList, false);
            mVideoCoverGoDetail.setVisibility(isDirectPlay ? View.GONE : View.VISIBLE);
            if (!this.bS) {
                UIUtils.setVisibility(mVideoCoverGoDetail, View.GONE);
            }
            UIUtils.setVisibility(mVideoCoverBack, View.GONE);
        }
    }

    public final void showRetry() {
        mVideoLoadingRetryLayout.setVisibility(View.VISIBLE);
        mVideoLoadingRetry.setVisibility(View.VISIBLE);
        mVideoLoadingProgress.setVisibility(View.GONE);
    }

    public final void showToolBar(boolean arg2) {
        this.showToolBar(arg2, false, false);
    }

    public final void showToolBar(boolean arg5, boolean arg6, boolean arg7) {
        MediaViewLayout v3_2;
        int v0;
        int v2 = View.GONE;
        if (this.callback != null) {
            if (!this.callback.isPrepared() && mVideoLoadingProgress.getVisibility() == View.VISIBLE) {
                v0 = 1;
            } else {
                v0 = 0;
            }
        } else {
            v0 = 0;
        }

        if ((this.isDirectPlay) || (arg7) || (this.I) || (this.J) || (this.isLiveVideo) || v0 != 0) {
            mVideoBottomLayout.setVisibility(v2);
        } else {
            mVideoBottomLayout.setVisibility(View.VISIBLE);
        }

        View v3 = mVideoLiveBottomLayout;
        v0 = this.isLiveVideo ? 0 : v2;
        v3.setVisibility(v0);
        SeekBar v3_1 = mSeekBar;
        v0 = arg6 ? v2 : 0;
        v3_1.setVisibility(v0);
        if (this.isFullscreen) {
            v0 = v2;
            v3_2 = this;
        } else if (arg6) {
            v0 = v2;
            v3_2 = this;
        } else {
            v0 = 0;
            v3_2 = this;
        }

        v3_2.setVideoMoreIvVisible(v0);
        TextView v3_3 = mVideoTimeLeftTime;
        v0 = arg6 ? v2 : 0;
        v3_3.setVisibility(v0);
        v3_3 = mVideoTimePlay;
        v0 = arg6 ? v2 : 0;
        v3_3.setVisibility(v0);
        v0 = arg6 ? v2 : 0;
        mVideoFullscreen.setVisibility(v0);
        if (!arg6 || (android.support.design.a.isTextEmpty(this.mThirdImageUrl))) {
            mMediaThirdParty.setVisibility(v2);
        } else {
            mMediaThirdParty.setVisibility(View.VISIBLE);
        }

        mVideoProgress.setVisibility(v2);
        if (this.isFullscreen) {
            mVideoTopLayout.setVisibility(View.VISIBLE);
            if (this.I) {
                mVideoFullscreenTitle.setVisibility(v2);
            } else {
                mVideoFullscreenTitle.setVisibility(View.VISIBLE);
            }
        } else if (arg7) {
            mVideoTopLayout.setVisibility(v2);
        }

        if (AppData.getInstance().isPosterAdClickEnabled()) {
            v0 = !arg5 || (this.J) || (this.I) || mVideoLoadingRetryLayout.getVisibility() == View.VISIBLE ? v2 : 0;
            mVideoPlay.setVisibility(v0);
        } else {
            v0 = !arg5 || (this.J) || mVideoLoadingRetryLayout.getVisibility() == View.VISIBLE ? v2 : 0;
            mVideoPlay.setVisibility(v0);
        }

        if (!this.isCellType && !this.isFullscreen) {
            if (!this.bV.contains(CtrlFlag.hideCloseBtn) && !arg7) {
                mVideoClose.setVisibility(View.VISIBLE);
            }
            if (!arg7) {
                v2 = 0;
            }
            mVideoBack.setVisibility(v2);
        }
    }

    public final boolean showTouchProgress(Context context, boolean right, long current, long total) {
        if (context != null && total > 0) {
            if (mVideoProgressDialog == null || this.needInitVideoProgressBar) {
                this.needInitVideoProgressBar = false;
                View videoProgressDialog = LayoutInflater.from(context).inflate(com.ss.android.article.browser.R.layout.video_progress_dialog, null);
                mDurationProgressBar = videoProgressDialog.findViewById(com.ss.android.article.browser.R.id.duration_progressbar);
                mTvCurrent = videoProgressDialog.findViewById(com.ss.android.article.browser.R.id.tv_current);
                mTvDuration = videoProgressDialog.findViewById(com.ss.android.article.browser.R.id.tv_duration);
                mDurationImageTip = videoProgressDialog.findViewById(com.ss.android.article.browser.R.id.duration_image_tip);
                mVideoProgressDialog = new Dialog(context, com.ss.android.article.browser.R.style.volume_dialog);
                mVideoProgressDialog.setContentView(videoProgressDialog);
                mVideoProgressDialog.getWindow().addFlags(8);
                mVideoProgressDialog.getWindow().addFlags(32);
                mVideoProgressDialog.getWindow().addFlags(16);
                mVideoProgressDialog.getWindow().setLayout(WRAP_CONTENT, WRAP_CONTENT);
                WindowManager.LayoutParams lp = mVideoProgressDialog.getWindow().getAttributes();
                lp.gravity = Gravity.CENTER;
                mVideoProgressDialog.getWindow().setAttributes(lp);
            }

            if (mDurationProgressBar != null) {
                mDurationProgressBar.setProgress(((int) (100 * current / total)));
            }

            if (mTvCurrent != null) {
                mTvCurrent.setText(convert2readableString(current));
            }

            if (mTvDuration != null) {
                mTvDuration.setText(" / " + convert2readableString(total));
            }

            if (mDurationImageTip != null) {
                if (right) {
                    mDurationImageTip.setBackgroundResource(com.ss.android.article.browser.R.drawable.p0);
                } else {
                    mDurationImageTip.setBackgroundResource(com.ss.android.article.browser.R.drawable.my);
                }
            }

            try {
                if (mVideoProgressDialog.isShowing()) {
                    return false;
                }

                mVideoProgressDialog.show();
                return true;
            } catch (Exception e) {
            }

            return false;
        } else {
            return false;
        }
    }

    public final boolean showVolume(Context context, int volume) {
        int v0_1;
        int v2 = 100;
        int v5 = -2;
        boolean v1 = false;
        if (context != null) {
            if (mVolumeDialog == null || (this.bP)) {
                this.bP = false;
                View videoVolumeDialog = LayoutInflater.from(context).inflate(com.ss.android.article.browser.R.layout.video_volume_dialog, null);
                mVolumeProgressBar = videoVolumeDialog.findViewById(com.ss.android.article.browser.R.id.volume_progressbar);
                mTvVolume = videoVolumeDialog.findViewById(com.ss.android.article.browser.R.id.tv_volume);
                mVolumeImageTip = videoVolumeDialog.findViewById(com.ss.android.article.browser.R.id.volume_image_tip);
                mVolumeDialog = new Dialog(context, com.ss.android.article.browser.R.style.volume_dialog);
                mVolumeDialog.setContentView(videoVolumeDialog);
                mVolumeDialog.getWindow().addFlags(8);
                mVolumeDialog.getWindow().addFlags(32);
                mVolumeDialog.getWindow().addFlags(16);
                mVolumeDialog.getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                WindowManager.LayoutParams lp = mVolumeDialog.getWindow().getAttributes();
                lp.gravity = 17;
                mVolumeDialog.getWindow().setAttributes(lp);
            }

            if (mVolumeProgressBar != null) {
                mVolumeProgressBar.setProgress(volume);
            }

            if (mTvVolume != null) {
                v0_1 = volume > v2 ? v2 : volume;
                if (v0_1 < 0) {
                    v0_1 = 0;
                }

                mTvVolume.setText(v0_1 + "%");
            } else {
                v0_1 = volume;
            }

            if (mVolumeImageTip != null) {
                if (v0_1 > 0) {
                    mVolumeImageTip.setBackgroundResource(com.ss.android.article.browser.R.drawable.addvolume_video);
                } else {
                    mVolumeImageTip.setBackgroundResource(com.ss.android.article.browser.R.drawable.closevolume_video);
                }
            }

            try {
                if (mVolumeDialog.isShowing()) {
                    return v1;
                }

                mVolumeDialog.show();
                v1 = true;
            } catch (Exception v0_2) {
            }
        }

        return v1;
    }

    public final void stopAutoPlayEndCover() {
        if ((this.isFullscreenAutoPlayEndCoverVisible()) || (this.isAutoPlayEndCoverVisible())) {
            String v0 = mContext.getString(com.ss.android.article.browser.R.string.next_video);
            mWeakHandler.removeCallbacks(mEndCoverCountdownRunnable);
            mAutoPlayDelaySeconds = 0;
            int v1 = v0.length();
            SpannableStringBuilder v2 = new SpannableStringBuilder(v0);
            v2.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(com.ss.android.article.browser.R.color.cg)), 0, v1, 33);
            UIUtils.setText(mFullscreenAutoPlayEndCoverTvAutoPlay, v2);
            UIUtils.setText(mTvAutoPlay, v2);
        }
    }

    public final void trySetTitleVisiable(boolean arg5) {
        int v0_1;
        TextView v1_1;
        TextView v0;
        int v1 = View.GONE;
        if ((this.I) || (this.J)) {
            mVideoTitle.setVisibility(v1);
        } else if (mVideoTitle != null) {
            if (this.isCellType) {
                if (this.mOuterVideoCellType != 2 && this.mOuterVideoCellType != 5) {
                    v0 = mVideoTitle;
                    if (arg5) {
                        v1_1 = v0;
                        v0_1 = 0;
                    } else {
                        int v3 = v1;
                        v1_1 = v0;
                        v0_1 = v3;
                    }
                } else {
                    v0 = mVideoTitle;
                    int v3 = v1;
                    v1_1 = v0;
                    v0_1 = v3;
                }
            } else {
                v0 = mVideoTitle;
                if (arg5) {
                    v1_1 = v0;
                    v0_1 = 0;
                } else {
                    int v3 = v1;
                    v1_1 = v0;
                    v0_1 = v3;
                }
            }

            v1_1.setVisibility(v0_1);
        }
    }

    public final void updateAdLeftTime(int arg7, int jumpCountdown) {
        mAdActionLayout.setTag(Integer.valueOf(jumpCountdown));
        mAdLeftTime.setText(String.valueOf(0));
        if (jumpCountdown > 0) {
            mAdJumpBtn.setText(mContext.getResources().getString(com.ss.android.article.browser.R.string.video_skip_ad_left_time, new Object[]{Integer.valueOf(0)}));
            mAdJumpBtn.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
        } else {
            mAdJumpBtn.setText(mContext.getResources().getString(com.ss.android.article.browser.R.string.video_skip_ad));
            mAdJumpBtn.setCompoundDrawablesWithIntrinsicBounds(0, 0, com.ss.android.article.browser.R.drawable.skipicon_ad_video, 0);
            mAdJumpBtn.setCompoundDrawablePadding(10);
        }
    }

    public final void updateAdPatchVideoPanel(boolean arg4) {
        if (arg4) {
            mVideoAdBottomLayout.setVisibility(View.VISIBLE);
            mAdActionLayout.setVisibility(View.VISIBLE);
        } else {
            mVideoAdBottomLayout.setVisibility(View.GONE);
            mAdActionLayout.setVisibility(View.GONE);
        }
    }

    final class BatteryChangedReceiver extends BroadcastReceiver {


        public final void onReceive(Context context, Intent intent) {
            int battery = intent.getExtras().getInt("level") * 100 / intent.getExtras().getInt("scale");
            if (battery == 100) {
                mBatteryLevel.setImageResource(com.ss.android.article.browser.R.drawable.battery_level_100);
            } else {
                if (battery < 100 && battery >= 80) {
                    mBatteryLevel.setImageResource(com.ss.android.article.browser.R.drawable.battery_level_90);
                } else if (battery < 80 && battery >= 60) {
                    mBatteryLevel.setImageResource(com.ss.android.article.browser.R.drawable.battery_level_70);
                } else if (battery < 60 && battery >= 40) {
                    mBatteryLevel.setImageResource(com.ss.android.article.browser.R.drawable.battery_level_50);
                } else if (battery < 40 && battery >= 10) {
                    mBatteryLevel.setImageResource(com.ss.android.article.browser.R.drawable.battery_level_30);
                } else if (battery >= 10) {
                } else {
                    mBatteryLevel.setImageResource(com.ss.android.article.browser.R.drawable.battery_level_10);
                }
            }
            Logger.d("MediaViewLayout", "battery:" + battery);
        }
    }

    final class MyOnGlobalLayoutListener implements ViewTreeObserver.OnGlobalLayoutListener {
        private WeakReference<View> mViewRef;

        MyOnGlobalLayoutListener(View view) {
            mViewRef = new WeakReference(view);
        }

        public final void onGlobalLayout() {
            View view = mViewRef.get();
            if (view != null && view.getWidth() > 0) {
                view.setTranslationX((float) view.getWidth());
                view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            }
        }
    }

    final class MediaViewLayoutHolder {
        RelativeLayout mVideoCoverContainer;
        ImageView mVideoCoverImage;
        TextView mVideoCoverGoDetail;
        ImageView mVideoCoverReplay;
        TextView mVideoAdGoDetail;
        RelativeLayout mVideoLoadingCover;
        AsyncImageView mVideoLoadingCoverImage;
        RelativeLayout mVideoAutoPlayLayout;
        View mAutoPlayEndCover;
        TextView mAutoPlayEndCoverTvAutoPlay;
        TextView mAutoPlayEndCoverTvVideoTitle;
        AsyncImageView mAutoPlayEndCoverVideoEndCoverImageIv;
        TextView mAutoPlayTvCancelAutoPlay;
        View mFullscreenAutoPlayEndCover;
        TextView mFullscreenAutoPlayEndCoverTvAutoPlay;
        TextView mFullscreenAutoPlayEndCoverTvVideoTitle;
        AsyncImageView mFullscreenAutoPlayEndCoverVideoEndCoverImageIv;
        TextView mFullscreenAutoPlayEndCoverTvCancelAutoPlay;
        View mFinishInfoLayout;
        DrawableButton mVideoFollowCompleteReplay;
        DrawableButton mVideoFollowCompleteShare;
        AsyncImageView mVideoFinishCoverImage;
        TextView mCoverTitle;
        DrawableButton mVideoTime;
        View mRLVideoEndCover;
        AlphaImageView mIvShareWechat;
        IRenderView mVideoSurface;
        AlphaImageView mIvShareMoment;
        AlphaImageView mIvShareQQ;
        AlphaImageView mIvShareQzone;
        View mLLReplay;
        View mAdActionLayout;
        TextView mAdLeftTime;
        TextView mAdJumpBtn;
        View mAdLeftJumpLine;
        View mVideoAdBottomLayout;
        ImageView mVideoAdFullscreen;
        View mVideoAdGoDetailBottom;
        View mVideoLiveBottomLayout;
        DrawableButton mVideoLiveTip;
        ImageView mVideoLiveFullScreen;
        AdButtonLayout mLargeButtonAd;
        TextView mAdSplashJumpBtn;
        FrameLayout mAdSplashIgnore;
        ImageView mAdSplashLogo;
        ImageView mAdSplashSkipLoading;
        ImageView mAdSplashHasWifiLoaded;
        View mVideoLiveCoverContainer;
        TextView mLiveVideoStatus;
        View mVideoCoverBack;
        View mVideoLiveCoverBack;
        TextView mVideoActionControlAreaRight;
        ViewGroup mVideoAreaRight;
        TextView mVideoBack;
        ImageView mIvWatermark;
        ImageView mVideoClose;
        View mVideoTopLayout;
        ImageView mVideoFullscreenBack;
        TextView mVideoTitle;
        TextView mVideoFullscreenTitle;
        TextView mVideoCurrentTime;
        ImageView mBatteryLevel;
        View mVideoBottomLayout;
        ImageView mVideoPlay;
        ImageView mVideoMoreIv;
        ImageView mVideoItemFeedMoreDot;
        ImageView mVideoBottomBarBGIv;
        SeekBar mVideoSeekBar;
        ProgressBar mVideoProgress;
        TextView mVideoTimeLeftTime;
        TextView mVideoTimePlay;
        AsyncImageView mMediaThirdParty;
        View mVideoLoadingRetryLayout;
        ImageView mVideoFullscreen;
        View mVideoLoadingProgress;
        View mVideoLoadingRetry;
        ImageView mVideoRetry;
        TextView mVideoRetryDes;
    }

    @TargetApi(value = 18)
    final class MyOnWindowFocusChangeListener implements OnWindowFocusChangeListener {
        private WeakReference<IRenderView> mRenderViewRef;

        MyOnWindowFocusChangeListener(IRenderView renderView) {
            mRenderViewRef = new WeakReference(renderView);
        }

        public final void onWindowFocusChanged(boolean hasFocus) {
            IRenderView renderView = mRenderViewRef.get();
            if (renderView != null && hasFocus && renderView != null && renderView.getView() != null) {
                renderView.getView().requestLayout();
            }
        }
    }
}

